-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Fix 3759 - uneditable & permanent defaults with additional properties #4490
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: Heath C <[email protected]>
@Piotr-Debicki I hope all is well... Still waiting for you to update your PR to avoid breaking API changes |
@heath-freenome Hey, sorry! I got caught up with work and this completely slipped my mind. I'll revisit this when I get some free time this week |
@Piotr-Debicki Hey, seems you didn't get the time you were hoping for. Any chance you can get it done by the end of September? |
@heath-freenome Hey, sorry (again). I unfortunately had a bunch of stuff added to my plate at once, but I should be able to finish this up by then, yeah |
@heath-freenome Hey, finally got to updating the PR. Let me know if you need any other changes here. Wasn't sure about versioning, so I just kept the convention + .01 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Piotr-Debicki Thanks for updating your PR... I hope you can respond to this feedback before we release v6 in less than a month.
|
||
### Changes to existing utility functions | ||
|
||
- `getDefaultFormState`: Added optional `initialDefaultsGenerated` boolean flag that indicates whether or not initial defaults have been generated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@heath-freenome LMK if this is okay
Co-authored-by: Heath C <[email protected]>
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
npx nx run-many --target=build --exclude=@rjsf/docs && npm run test:update
to update snapshots, if needed.