Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 3759 - uneditable & permanent defaults with additional properties #4490

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

Piotr-Debicki
Copy link

@Piotr-Debicki Piotr-Debicki commented Feb 7, 2025

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

  • 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant