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

Fix 3759 - uneditable & permanent defaults with additional properties

Open Piotr-Debicki opened this issue 9 months ago • 0 comments

Reasons for making this change

Fixes #3759

Additional properties with defaults set currently creates a permanent key-value pair that is essentially uneditable. Trying to edit the key creates an entirely new key value entry on blur while still keeping the default key-value pair. The default key-value pair is also not deletable. Solution here generates defaults for additional properties once on form initialization, and then skips regeneration on any form update

This solution works for root & nested additionalProperties (see tests) Allows for 'reset' form to regenerate additionalProperties defaults Also fixes the issue I mentioned in the Closed PR with custom formData not being applied when generating additionalProperties defaults

Checklist

  • [x] I'm updating documentation
  • [x] I'm adding or updating code
    • [x] 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.
    • [x] I've updated docs if needed
    • [x] 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

Piotr-Debicki avatar Feb 07 '25 21:02 Piotr-Debicki