react-jsonschema-form icon indicating copy to clipboard operation
react-jsonschema-form copied to clipboard

Fix: made small changes to utility functions to fix #3997, #4314 and #4322

Open heath-freenome opened this issue 1 year ago • 3 comments

Reasons for making this change

Fixes #3977, #4314, #4322

  • In @rjsf/utils, made the following changes:
    • Added mergeDefaultsIntoFormData option to Experimental_DefaultFormStateBehavior type to control how to handle merging of defaults
    • Updated mergeDefaultsWithFormData() to add new optional defaultSupercedesUndefined that when true uses the defaults rather than undefined formData
    • Updated getDefaultFormState() to pass true to mergeDefaultsWithFormData for defaultSupercedesUndefined when mergeDefaultsIntoFormData has the value useDefaultIfFormDataUndefined
    • Updated getClosestMatchingOption() to improve the scoring function so that an object container that matches a key gets an extra point
  • In @rjsf/core, updated MultiSchemaField to call onChange after setting the new option in state rather than before
  • In the playground, added controls for the new mergeDefaultsIntoFormData option
    • Moved the Show Error List component over one column, making it inline radio buttons rather than a select
  • Updated the CHANGELOG.md accordingly

Checklist

  • [ ] I'm updating documentation
  • [ ] I'm adding or updating code
    • [ ] I've added and/or updated tests. I've run npx nx run-many --target=build --exclude=@rjsf/docs && npm run test:update to update snapshots, if needed.
    • [ ] I've updated docs if needed
    • [ ] I've updated the changelog with a description of the PR
  • [ ] I'm adding a new feature
    • [ ] I've updated the playground with an example use of the feature
Screenshot 2024-10-18 at 3 32 49 PM

heath-freenome avatar Oct 05 '24 00:10 heath-freenome

please merge this pr fast

reshmarevi-kv avatar Oct 17 '24 11:10 reshmarevi-kv

please merge this pr fast

I am having to deal with a regression that was detected in testing and my job is quite busy. Working as fast as I can, sorry

heath-freenome avatar Oct 17 '24 17:10 heath-freenome

Ok, in order to avoid regressions, I added a new, optional mergeDefaultsIntoFormData prop to Experimental_DefaultFormStateBehavior which can be used to fix the issue seen in #4322

heath-freenome avatar Oct 18 '24 22:10 heath-freenome