You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The issue we are seeing is that when we switch options, the default values are restored only for the fields that are common to both the options. Eg. Link to playground
In this example, when you switch from option-1 to option-2 and then back to option-1, default value for lorem is not restored.
Expected Behavior
Default values should be retained when switching between the options of oneOf
Steps To Reproduce
Switch between options and you'll notice that the default values are not retained. Link to playground
Environment
- OS:
- Node:
- npm:
Anything else?
This issue might be similar to #4208 but that one is for the same keys while the example I'm sharing is about the unique keys in the options of oneOf.
Same behavior is expected for anyOf.
The text was updated successfully, but these errors were encountered:
…rjsf-team#4322Fixesrjsf-team#3997 and rjsf-team#4322
- In `@rjsf/utils`, made the following changes:
- Updated `mergeDefaultsWithFormData()` to not overwrite a default when the formData has an undefined value
- Updated `getClosestMatchingOption()` to improve the scoring function so that an object container that matches a key gets an extra point
- In `@rjsf/core`, updated `MultiSchemaField` to call `onChange` after setting the new option in state rather than before
- Updated the `CHANGELOG.md` accordingly
Prerequisites
What theme are you using?
core
Version
5.x
Current Behavior
The issue we are seeing is that when we switch options, the default values are restored only for the fields that are common to both the options. Eg. Link to playground
In this example, when you switch from option-1 to option-2 and then back to option-1, default value for lorem is not restored.
Expected Behavior
Default values should be retained when switching between the options of
oneOf
Steps To Reproduce
Switch between options and you'll notice that the default values are not retained.
Link to playground
Environment
Anything else?
This issue might be similar to #4208 but that one is for the same keys while the example I'm sharing is about the unique keys in the options of oneOf.
Same behavior is expected for anyOf.
The text was updated successfully, but these errors were encountered: