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
onChangecallback works so that it queues up changes at the field level rather than the whole formData levelpackage*.jsonto installis-ciand changedprepareto be"is-ci || husky".eslintrc.jsonto add"react-hooks/exhaustive-deps": "error",so that we use hook dependencies properly@rjsf/core'sCheckboxesWidget, andplayground'sHeaderandPlaygroundto fix the dependencies@rjsf/daisyui'sDateTimeWidgetandDateWidgetto fix the dependenciesdocs/index.mdto remove the details about older versions since we have them nowplayground's samples to fix a few issues in themcustomArray.tsxto fix theArrayFieldTemplateto use the correctbuttonsPropsprop on theelementcustomFieldAnyOf.tsxto make it properly use the theme components by switching toFieldTemplate,StringFieldandNumberField@rjsf/coreand@rjsf/mantinetheme'sAltDateWidgetto fix a bug with how the clear button works with the updatedonChangeprocess@rjsf/utilsto make a BREAKING CHANGE to theFieldProps.onChangeprop to inject apath?: (number | string)[]before theErrorSchemaparameter@rjsf/coreto fix Custom Field onChange not working #3367 as follows:BooleanFieldandStringFieldto add anonWidgetChangeintermediate callback to insert[]into the field'sonChange()callbackArrayFieldandObjectFieldto inject the newpathparameter as neededonChangehandler pass the value rather than building the wholeformDataanderrorSchemaLayoutGridFieldto updateonFieldChange()to add thepathon the handler and use thedottedPathto pass down the realpathtoonChangeLayoutMultiSchemaField,MultiSchemaField,NullFieldandSchemaFieldto add thepathon the handlers and passing toonChangeFormto refactor theonChangehandler to support queuing changes into a newpendingChanges[]array and calling the newprocessPendingChange()functionprocessPendingChange()function takes thenewValueand thepathand sets that value into theformDataand thenewErrorSchemainto theerrorSchemaArrayField,ObjectFieldandStringFieldtests for the newonChangehandling mechanismLayoutGridFieldandLayoutMultiSchemaFieldto deal with the newonChangehandling mechanismFormto add testing of near simultaneous changes to verify the fix workscustom-widgets-fields.mddocumentation to reflect the changes to theonChangehandlingv6.x upgrade guide.mdto document the breaking changes around theFieldProps.onChangehandlingCHANGELOG.mdfile accordinglyChecklist
npx nx run-many --target=build --exclude=@rjsf/docs && npm run test:updateto update snapshots, if needed.