Skip to content

fix(core): prevent cleared fields from re-defaulting when another field is cleared (#5125 regression)#5138

Open
yap-house wants to merge 2 commits into
rjsf-team:mainfrom
yap-house:fix-issue-5125
Open

fix(core): prevent cleared fields from re-defaulting when another field is cleared (#5125 regression)#5138
yap-house wants to merge 2 commits into
rjsf-team:mainfrom
yap-house:fix-issue-5125

Conversation

@yap-house

Copy link
Copy Markdown

Reasons for making this change

This fixes a regression introduced in #5136.
After clearing field A, clearing field B caused field A to be re-populated with its schema default.
The fix uses _set(formData, path, undefined) instead of _unset to keep the cleared key present in state, preventing mergeDefaultsWithFormData from re-applying the default. A new private helper omitUndefinedLeaves() strips undefined-valued keys before AJV validation to preserve the #4518 fix.

fixes #5125

Checklist

  • I'm updating documentation
  • I'm adding or updating code
    • I've added and/or updated tests. I've run pnpm exec nx run-many --target=build --exclude=@rjsf/docs && pnpm 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

Development

Successfully merging this pull request may close these issues.

About form behavior when empty input is performed

1 participant