Skip to content

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

Co-authored-by: Heath C <[email protected]>
@heath-freenome
Copy link
Member

@Piotr-Debicki I hope all is well... Still waiting for you to update your PR to avoid breaking API changes

@Piotr-Debicki
Copy link
Author

Piotr-Debicki commented Aug 12, 2025

@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

@heath-freenome
Copy link
Member

@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?

@Piotr-Debicki
Copy link
Author

@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

@Piotr-Debicki
Copy link
Author

@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

Copy link
Member

@heath-freenome heath-freenome left a 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
Copy link
Author

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

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

Successfully merging this pull request may close these issues.

Object defaults for "additionalProperties" result in rows that cannot be deleted and have side effects when modified
2 participants