You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix 3367 so that multiple near simultaneous changes don't lose data (#4721)
* Fix 3367 so that multiple near simultaneous changes don't lose data
Fixes#3367 by changing how the `onChange` callback works so that it queues up changes at the field level rather than the whole formData level
- Updated `package*.json` to install `is-ci` and changed `prepare` to be `"is-ci || husky"`
- Updated `.eslintrc.json` to add `"react-hooks/exhaustive-deps": "error",` so that we use hook dependencies properly
- Updated `@rjsf/core`'s `CheckboxesWidget`, and `playground`'s `Header` and `Playground` to fix the dependencies
- Updated `@rjsf/daisyui`'s `DateTimeWidget` and `DateWidget` to fix the dependencies
- Updated `docs/index.md` to remove the details about older versions since we have them now
- Updated `playground`'s samples to fix a few issues in them
- Updated `customArray.tsx` to fix the `ArrayFieldTemplate` to use the correct `buttonsProps` prop on the `element`
- Updated `customFieldAnyOf.tsx` to make it properly use the theme components by switching to `FieldTemplate`, `StringField` and `NumberField`
- Updated `@rjsf/core` and `@rjsf/mantine` theme's `AltDateWidget` to fix a bug with how the clear button works with the updated `onChange` process
- Updated `@rjsf/utils` to make a BREAKING CHANGE to the `FieldProps.onChange` prop to inject a `path?: (number | string)[]` before the `ErrorSchema` parameter
- Updated `@rjsf/core` to fix#3367 as follows:
- Updated `BooleanField` and `StringField` to add an `onWidgetChange` intermediate callback to insert `[]` into the field's `onChange()` callback
- Updated `ArrayField` and `ObjectField` to inject the new `path` parameter as needed
- Also, made the main `onChange` handler pass the value rather than building the whole `formData` and `errorSchema`
- Updated `LayoutGridField` to update `onFieldChange()` to add the `path` on the handler and use the `dottedPath` to pass down the real `path` to `onChange`
- Updated `LayoutMultiSchemaField`, `MultiSchemaField`, `NullField` and `SchemaField` to add the `path` on the handlers and passing to `onChange`
- Updated `Form` to refactor the `onChange` handler to support queuing changes into a new `pendingChanges[]` array and calling the new `processPendingChange()` function
- The `processPendingChange()` function takes the `newValue` and the `path` and sets that value into the `formData` and the `newErrorSchema` into the `errorSchema`
- Updated the custom fields in the tests for `ArrayField`, `ObjectField` and `StringField` tests for the new `onChange` handling mechanism
- Updated the tests for `LayoutGridField` and `LayoutMultiSchemaField` to deal with the new `onChange` handling mechanism
- Updated the tests for `Form` to add testing of near simultaneous changes to verify the fix works
- Updated the `custom-widgets-fields.md` documentation to reflect the changes to the `onChange` handling
- Updated the `v6.x upgrade guide.md` to document the breaking changes around the `FieldProps.onChange` handling
- Updated the `CHANGELOG.md` file accordingly
* - Fixed up a few little things
* - More minor fixes
Copy file name to clipboardExpand all lines: CHANGELOG.md
+8Lines changed: 8 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,6 +21,9 @@ should change the heading of the (upcoming) version to include a major version b
21
21
22
22
- Added support for dynamic UI schema in array fields - the `items` property in `uiSchema` can now accept a function that returns a UI schema based on the array item's data, index, and form context ([#4706](https://github.com/rjsf-team/react-jsonschema-form/pull/4706))
23
23
- Fixed checkbox widget to use current value instead of event target in onFocus/onBlur handlers, fixing [#4704](https://github.com/rjsf-team/react-jsonschema-form/issues/4704)
24
+
- Updated all of the `XxxxField` components and `Form` to handle the new `path` parameter in `FieldProps.onChange`, making `Form` queue up changes so that they are all processed and no data is lost, fixing [#3367](https://github.com/rjsf-team/react-jsonschema-form/issues/3367)
25
+
- Updated a bug in `AltDateWidget` related to the `clear` button not working after the fix for [#3367](https://github.com/rjsf-team/react-jsonschema-form/issues/3367)
26
+
- Fixed the missing hook dependencies for the `CheckboxesWidget` so that they work properly
24
27
25
28
## @rjsf/chakra-ui
26
29
@@ -29,6 +32,7 @@ should change the heading of the (upcoming) version to include a major version b
29
32
## @rjsf/daisyui
30
33
31
34
- Fixed checkbox widget to use current value instead of event target in onFocus/onBlur handlers, fixing [#4704](https://github.com/rjsf-team/react-jsonschema-form/issues/4704)
35
+
- Fixed the missing hook dependencies in the `DateTimeWidget` and `DateWidget` so that they work properly
32
36
33
37
## @rjsf/fluentui-rc
34
38
@@ -62,6 +66,7 @@ should change the heading of the (upcoming) version to include a major version b
62
66
63
67
- Updated `UiSchema` type to support dynamic array item UI schemas - the `items` property can now be either a `UiSchema` object or a function that returns a `UiSchema` ([#4706](https://github.com/rjsf-team/react-jsonschema-form/pull/4706))
64
68
- Added `title` property to `RJSFValidationError`[PR](https://github.com/rjsf-team/react-jsonschema-form/pull/4700)
69
+
- BREAKING CHANGE: Updated the `FieldProps` interface's `onChange` handler to inject a new optional `path` before the `ErrorSchema` parameter as part of the fix for [#3367](https://github.com/rjsf-team/react-jsonschema-form/issues/3367)
65
70
66
71
## @rjsf/validator-ajv8
67
72
@@ -72,6 +77,9 @@ should change the heading of the (upcoming) version to include a major version b
72
77
- Added comprehensive documentation for dynamic UI schema feature with TypeScript examples ([#4706](https://github.com/rjsf-team/react-jsonschema-form/pull/4706))
73
78
- Updated array documentation to reference the new dynamic UI schema capabilities ([#4706](https://github.com/rjsf-team/react-jsonschema-form/pull/4706))
74
79
- Updated nearly all of the libraries in the `package.json` files to the latest non-breaking versions
80
+
- Fixed the broken `Custom Array` sample
81
+
- Improved the `Any Of with Custom Field` sample so that it renders using the appropriate theme components
82
+
- Updated the `custom-widgets-fields.md` and `v6.x upgrade guide.md` to document the BREAKING CHANGE to the `FieldProps.onChange` behavior
The react-jsonschema-form docs have been moved [here](https://rjsf-team.github.io/react-jsonschema-form/docs).
4
-
5
-
We are in the process of migrating our versioned documentation. For documentation prior to version 5.0.0, please select the version in the bottom-right corner of this page.
"bump-all-packages": "echo 'NOTE: Make sure to sanity check the playground locally before commiting changes' && npm update --save && npm install && npm run lint && npm run build && npm run test",
0 commit comments