Rjsf-team from React-jsonschema-form Repository

Apache License 2.0

05 Oct 2022

Nickgros

Adding properties should work when `additionalProperties` is `true`

Fixes #3179

Conversion of ObjectField to TypeScript caused a regression where additionalProperties: true was not properly evaluated when adding a property.

  • Change ObjectField logic to handle additionalProperties: true.
  • Add tests to validate some of the logic in handleAddClick, including the regression

Forked On 05 Oct 2022 at 08:15:14

Nickgros

Should have just added a blank commit to start the CI pipeline...thanks for catching!
On 05 Oct 2022 at 08:15:14

Nickgros

Adding properties should work when `additionalProperties` is `true`

Fixes #3179

Conversion of ObjectField to TypeScript caused a regression where additionalProperties: true was not properly evaluated when adding a property.

  • Change ObjectField logic to handle additionalProperties: true.
  • Add tests to validate some of the logic in handleAddClick, including the regression

Merged On 05 Oct 2022 at 08:15:14

Nickgros

Commented On 05 Oct 2022 at 08:15:14

Ldorofeeva

fix(@rjsf/chakra-ui) Unify appearance of chakra-ui SelectWidget for single and multiple-choice

Created On 05 Oct 2022 at 08:09:01

Heath-freenome

Adding properties should work when `additionalProperties` is `true`

Fixes #3179

Conversion of ObjectField to TypeScript caused a regression where additionalProperties: true was not properly evaluated when adding a property.

  • Change ObjectField logic to handle additionalProperties: true.
  • Add tests to validate some of the logic in handleAddClick, including the regression

Merged On 05 Oct 2022 at 07:51:33

Heath-freenome

Commented On 05 Oct 2022 at 07:51:33

Heath-freenome

Adding properties should work when `additionalProperties` is `true`

Fixes #3179

Conversion of ObjectField to TypeScript caused a regression where additionalProperties: true was not properly evaluated when adding a property.

  • Change ObjectField logic to handle additionalProperties: true.
  • Add tests to validate some of the logic in handleAddClick, including the regression

Forked On 05 Oct 2022 at 07:51:32

Heath-freenome

```suggestion - Extended `Form.onChange` to optionally return the `id` of the field that caused the change, fixing [#2768](https://github.com/rjsf-team/react-jsonschema-form/issues/2768) ```
On 05 Oct 2022 at 07:51:32

Nickgros

Adding properties should work when `additionalProperties` is `true`

Fixes #3179

Conversion of ObjectField to TypeScript caused a regression where additionalProperties: true was not properly evaluated when adding a property.

  • Change ObjectField logic to handle additionalProperties: true.
  • Add tests to validate some of the logic in handleAddClick, including the regression

Forked On 05 Oct 2022 at 07:23:37

Nickgros

Making a small change to kick off the GH action runner ```suggestion - Extended `Form.onChange` to optionally return the `id` of the field that caused the change, fixing [#2768](https://github.com/rjsf-team/react-jsonschema-form/pull/2768) ```
On 05 Oct 2022 at 07:23:37

Nickgros

Adding properties should work when `additionalProperties` is `true`

Fixes #3179

Conversion of ObjectField to TypeScript caused a regression where additionalProperties: true was not properly evaluated when adding a property.

  • Change ObjectField logic to handle additionalProperties: true.
  • Add tests to validate some of the logic in handleAddClick, including the regression

Merged On 05 Oct 2022 at 07:23:38

Nickgros

Commented On 05 Oct 2022 at 07:23:38

Nickgros

Adding properties should work when `additionalProperties` is `true`

Fixes #3179

Conversion of ObjectField to TypeScript caused a regression where additionalProperties: true was not properly evaluated when adding a property.

  • Change ObjectField logic to handle additionalProperties: true.
  • Add tests to validate some of the logic in handleAddClick, including the regression

Merged On 05 Oct 2022 at 07:22:13

Nickgros

Commented On 05 Oct 2022 at 07:22:13

Nickgros

Adding properties should work when `additionalProperties` is `true`

Fixes #3179

Conversion of ObjectField to TypeScript caused a regression where additionalProperties: true was not properly evaluated when adding a property.

  • Change ObjectField logic to handle additionalProperties: true.
  • Add tests to validate some of the logic in handleAddClick, including the regression

Forked On 05 Oct 2022 at 07:22:12

Nickgros

```suggestion - Fixed a regression in earlier v5 beta versions where additional properties could not be added when `additionalProperties` was `true` ([#3719](https://github.com/rjsf-team/react-jsonschema-form/pull/3719)). ```
On 05 Oct 2022 at 07:22:12

Heath-freenome

ButtonTemplates: differentiate between array and object AddButton

Prerequisites

What theme are you using?

core

Is your feature request related to a problem? Please describe.

v5 adds ButtonTemplates.AddButton, but in my case we want to use different icons between adding items to an array vs adding additionalProperties to an object

Describe the solution you'd like

  • Different button templates for the add to array and add to object
  • OK to have one fall back to the other if needed to avoid a breaking change or to keep the interface simple

Describe alternatives you've considered

No response

Forked On 05 Oct 2022 at 04:47:05

Heath-freenome

@nickgros Maybe also consider doing the Remove button the same way?

Commented On 05 Oct 2022 at 04:47:05

Heath-freenome

fix(utils): omit computedDefault of empty objects

Reasons for making this change

Fixes #2150 and #2708. See this playground

If there are no defaults, computedDefault will still create an empty object here. As a result, ajv assumes that the field should exist and is failing the validation if it has any required fields.

Forked On 05 Oct 2022 at 04:44:31

Heath-freenome

@heath-freenome to make sure we're on the same page: you are suggesting to run this.ajv.validate(schema, formData); on formData instead of newFormData and only use the newFormData for the custom validation? Am I right?

I wonder if we should call getDefaultFormState twice - once with includeUndefinedValues = false for the regular validation and once with true for the custom validation

There is some sense to that as well... Go with that.

Commented On 05 Oct 2022 at 04:44:31

Heath-freenome

Adding properties should work when `additionalProperties` is `true`

Fixes #3719

Conversion of ObjectField to TypeScript caused a regression where additionalProperties: true was not properly evaluated when adding a property.

  • Change ObjectField logic to handle additionalProperties: true.
  • Add tests to validate some of the logic in handleAddClick, including the regression

Merged On 05 Oct 2022 at 04:04:09

Heath-freenome

Commented On 05 Oct 2022 at 04:04:09

Nickgros

Adding properties should work when `additionalProperties` is `true`

Fixes #3719

Conversion of ObjectField to TypeScript caused a regression where additionalProperties: true was not properly evaluated when adding a property.

  • Change ObjectField logic to handle additionalProperties: true.
  • Add tests to validate some of the logic in handleAddClick, including the regression

Merged On 05 Oct 2022 at 03:56:53

Nickgros

Commented On 05 Oct 2022 at 03:56:53

Nickgros

Adding properties should work when `additionalProperties` is `true`

Created On 05 Oct 2022 at 03:56:13

Nickgros

Adding properties should work when `additionalProperties` is `true`

Fixes #3719

Conversion of ObjectField to TypeScript caused a regression where additionalProperties: true was not properly evaluated when adding a property.

  • Change ObjectField logic to handle additionalProperties: true.
  • Add tests to validate some of the logic in handleAddClick, including the regression

Forked On 05 Oct 2022 at 03:56:53

Nickgros

```suggestion // Specify that additionalProperties is true ```
On 05 Oct 2022 at 03:56:53

Nickgros

Conditional property is not added to the form if its type conflicts with `additionalProperties`

Prerequisites

What theme are you using?

core

Version

5.0.0-beta.10

Current Behavior

My schema should add a "string" field but it only does so when additionalProperties is

  • undefined
  • true (this is not a real workaround because of #3179)
  • `{ "type": "string" }

This warning is logged to the console when the field should be added:

could not merge subschemas in allOf:
Error: Could not resolve values for path:"properties.state.type". They are probably incompatible. Values: 
"string"
"number" 

Expected Behavior

The conditional field should appear - I should be able to customize additionalProperties and have conditional fields that do not match the additionalProperties schema.

Steps To Reproduce

Link to reproduction in current playground

Environment

Playground 5.0.0-beta.10 

Anything else?

No response

Forked On 05 Oct 2022 at 03:28:08

Nickgros

Looks like the change happened in ObjectField in the TypeScript conversion: https://github.com/rjsf-team/react-jsonschema-form/commit/f7a2affe39a604b8aa6766dc36d54074a9b0b41d

Commented On 05 Oct 2022 at 03:28:08

Ranihorev

fix(utils): omit computedDefault of empty objects

Reasons for making this change

Fixes #2150 and #2708. See this playground

If there are no defaults, computedDefault will still create an empty object here. As a result, ajv assumes that the field should exist and is failing the validation if it has any required fields.

Forked On 05 Oct 2022 at 01:57:06

Ranihorev

I can but I'm still not sure how we want to treat custom validations in this case. What is the expected behavior?

@ranihorev Here is what I propose... In both of the validators, let's try moving

 const newFormData = getDefaultFormState<T>(
      this,
      schema,
      formData,
      rootSchema,
      true
    ) as T; 

to right before the customValidate(...) using the formData in the this.ajv.validate() call.

I've sanity checked the tests with that change and it seems to work. Then make your change in the utils so that it continues to respect the includeUndefinedValues flag.

@heath-freenome to make sure we're on the same page: you are suggesting to run this.ajv.validate(schema, formData); on formData instead of newFormData and only use the newFormData for the custom validation? Am I right?

I wonder if we should call getDefaultFormState twice - once with includeUndefinedValues = false for the regular validation and once with true for the custom validation

Commented On 05 Oct 2022 at 01:57:06

Ranihorev

fix(utils): omit computedDefault of empty objects

Reasons for making this change

Fixes #2150 and #2708. See this playground

If there are no defaults, computedDefault will still create an empty object here. As a result, ajv assumes that the field should exist and is failing the validation if it has any required fields.

Forked On 05 Oct 2022 at 01:34:07

Ranihorev

@heath-freenome I started porting the change but I'm seeing unrelated TS errors when running the tests here

 src/components/fields/SchemaField.tsx:148:49 - error TS2554: Expected 1-2 arguments, but got 3.

    148       return onChange(formData, newErrorSchema, theId);
                                                        ~~~~~ 

Do we ignore TS errors somewhere?

Commented On 05 Oct 2022 at 01:34:07

Caloudinou

started

Started On 05 Oct 2022 at 12:51:59

MatinF

Tabs

His there a way to implement a form in multiple tabs ?

Like that ? https://react-bootstrap.github.io/components/tabs/

Forked On 05 Oct 2022 at 10:49:14

MatinF

I believe this issue could be solved by resolving this other issue: https://github.com/rjsf-team/react-jsonschema-form/issues/1157

Commented On 05 Oct 2022 at 10:49:14

MatinF

Multiple pages proposal

Prerequisites

Description

It would be nice to have multiple pages in a form. As a first pass, I'm proposing something like the following in the uiSchema:

{
    "ui:options": {
        "pages": [
            {
                "title": "Page 1",
                "ui:order": [
                    "name",
                    "address",
                    "email"
                ]
            },
            {
                "title": "Page 2",
                "ui:order": [
                    "zipcode",
                    "abc"
                ]
            }
        ]
    }
} 

This would put everything in all pages within a single schema. In the case we have an array of required elements, then, perhaps validation errors could show only at the end once all pages are completed.

Not sure if this is the right way to do it; would appreciate some feedback!

Forked On 05 Oct 2022 at 10:02:59

MatinF

@mavarazy just wanted to check if you had the chance to look further at this?

Commented On 05 Oct 2022 at 10:02:59

VietMaiExe

A React component for building Web forms from JSON Schema.

Forked On 05 Oct 2022 at 09:50:24

VietMaiExe

A React component for building Web forms from JSON Schema.

Forked On 05 Oct 2022 at 09:45:20

Krebbl

ExtraErrors are merged into errorSchema again and again

Prerequisites

What theme are you using?

core

Version

5.x Beta.10

Current Behavior

The passed extraErrors are rendered multiple times when typing into an input field.

Expected Behavior

The extraErrors should only be displayed once.

Steps To Reproduce

See example: https://codesandbox.io/s/vigilant-violet-8txkdr

Given the following Form config:

import validator from "@rjsf/validator-ajv6";
import Form from "@rjsf/core";

const schema = {
    "$schema": "http://json-schema.org/draft-07/schema#",
    "type": "object",
    "properties": {
        "email": {
            "type": "string",
            "format": "email"
        },
        "password": {
            "type": "string"
        },
        "passwordConfirmation": {
            "type": "string"
        }
    },
    "required": [
        "email",
        "password",
        "passwordConfirmation"
    ],
    "additionalProperties": false
}
...
<Form
   validator={validator}
   extraErrors={{email: {__errors: ["test"]}}}
   schema={schema}
   onSubmit={handleSubmit}
> 

When typing something into the password field, the extra errors are appended in the UI again and again.

Environment

- OS: MaxOS
- Node: 16.7
- npm: 8.15 

Anything else?

No response

Forked On 05 Oct 2022 at 05:56:57

Krebbl

I'm not able to reproduce this issue on the main branch, so it seems to be fixed there. Waiting for the next beta release now.

Commented On 05 Oct 2022 at 05:56:57

Rbozac

started

Started On 05 Oct 2022 at 04:24:27

About Repository

A React component for building Web forms from JSON Schema.
Language: TypeScript
Star: 11909
Fork: 1960
Watchers: 11909
Open Issues: 384
https://github.com/rjsf-team/react-jsonschema-form
Apache License 2.0
Last updated: 05 Oct 2022
Tropics: