Fix 3367 so that multiple near simultaneous changes don't lose data #4721
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reasons for making this change
Fixes #3367 by changing how the
onChange
callback works so that it queues up changes at the field level rather than the whole formData levelpackage*.json
to installis-ci
and changedprepare
to be"is-ci || husky"
.eslintrc.json
to add"react-hooks/exhaustive-deps": "error",
so that we use hook dependencies properly@rjsf/core
'sCheckboxesWidget
, andplayground
'sHeader
andPlayground
to fix the dependencies@rjsf/daisyui
'sDateTimeWidget
andDateWidget
to fix the dependenciesdocs/index.md
to remove the details about older versions since we have them nowplayground
's samples to fix a few issues in themcustomArray.tsx
to fix theArrayFieldTemplate
to use the correctbuttonsProps
prop on theelement
customFieldAnyOf.tsx
to make it properly use the theme components by switching toFieldTemplate
,StringField
andNumberField
@rjsf/core
and@rjsf/mantine
theme'sAltDateWidget
to fix a bug with how the clear button works with the updatedonChange
process@rjsf/utils
to make a BREAKING CHANGE to theFieldProps.onChange
prop to inject apath?: (number | string)[]
before theErrorSchema
parameter@rjsf/core
to fix Custom Field onChange not working #3367 as follows:BooleanField
andStringField
to add anonWidgetChange
intermediate callback to insert[]
into the field'sonChange()
callbackArrayField
andObjectField
to inject the newpath
parameter as neededonChange
handler pass the value rather than building the wholeformData
anderrorSchema
LayoutGridField
to updateonFieldChange()
to add thepath
on the handler and use thedottedPath
to pass down the realpath
toonChange
LayoutMultiSchemaField
,MultiSchemaField
,NullField
andSchemaField
to add thepath
on the handlers and passing toonChange
Form
to refactor theonChange
handler to support queuing changes into a newpendingChanges[]
array and calling the newprocessPendingChange()
functionprocessPendingChange()
function takes thenewValue
and thepath
and sets that value into theformData
and thenewErrorSchema
into theerrorSchema
ArrayField
,ObjectField
andStringField
tests for the newonChange
handling mechanismLayoutGridField
andLayoutMultiSchemaField
to deal with the newonChange
handling mechanismForm
to add testing of near simultaneous changes to verify the fix workscustom-widgets-fields.md
documentation to reflect the changes to theonChange
handlingv6.x upgrade guide.md
to document the breaking changes around theFieldProps.onChange
handlingCHANGELOG.md
file accordinglyChecklist
npx nx run-many --target=build --exclude=@rjsf/docs && npm run test:update
to update snapshots, if needed.