-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Switching between two oneOf option returns undefined form data #4314
Comments
Looks like a duplicate of #3711 ? |
Thank you @nickgros for reading my issue The current behavior I've mentioned is when changing back to I wish this information would helps you understand |
We're also seeing the issue in #3977 in this playground, but not sure if fixing that will fix this |
…4322 (#4329) * Fix: made small changes to utility functions to fix #3997 and #4322 Fixes #3997 and #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 * - In order to avoid regressions, added a new `mergeDefaultsWithFormData` prop to the `Experimental_DefaultFormStateBehavior` - Updated `mergeDefaultsWithFormData()` to add new optional `defaultSupercedesUndefined` that when true uses the defaults rather than `undefined` formData - Updated `getDefaultFormState()` to pass true to `mergeDefaultsWithFormData` for `defaultSupercedesUndefined` when `mergeDefaultsIntoFormData` has the value `useDefaultIfFormDataUndefined` - Updated the documentation for the new capabilities - Updated the playground to add controls for the new `mergeDefaultsIntoFormData` option - moved the `Show Error List` component over one column, making it inline radio buttons rather than a select * - Improved documentation a teeny bit * - More doc improvements * - Responded to reviewer feedback * - Fixed broken links * - Added section header for wrapping BaseInputTemplate * - Updated CHANGELOG.md
Seems like it is fixed! |
Prerequisites
What theme are you using?
core
Version
5.2.0
Current Behavior
Using this json Schema
when form is first initialized formData is
{increment: {}}
and when I change toreset
formData is set to{increment: undefined, reset: {}}
and again when change toincrement
formData is{increment: undefined, reset: undefined}
Expected Behavior
When changing back to option
increment
It should be{increment: {}}
not{increment: undefined, reset: undefined}
Steps To Reproduce
https://rjsf-team.github.io/react-jsonschema-form/#eyJmb3JtRGF0YSI6eyJyZXNldCI6e319LCJzY2hlbWEiOnsiJHNjaGVtYSI6Imh0dHA6Ly9qc29uLXNjaGVtYS5vcmcvZHJhZnQtMDcvc2NoZW1hIyIsInRpdGxlIjoiRXhlY3V0ZU1zZyIsIm9uZU9mIjpbeyJ0eXBlIjoib2JqZWN0IiwicmVxdWlyZWQiOlsiaW5jcmVtZW50Il0sInByb3BlcnRpZXMiOnsiaW5jcmVtZW50Ijp7InR5cGUiOiJvYmplY3QifX0sImFkZGl0aW9uYWxQcm9wZXJ0aWVzIjpmYWxzZX0seyJ0eXBlIjoib2JqZWN0IiwicmVxdWlyZWQiOlsicmVzZXQiXSwicHJvcGVydGllcyI6eyJyZXNldCI6eyJ0eXBlIjoib2JqZWN0IiwicmVxdWlyZWQiOlsiY291bnQiXSwicHJvcGVydGllcyI6eyJjb3VudCI6eyJ0eXBlIjoiaW50ZWdlciIsImZvcm1hdCI6ImludDMyIn19fX0sImFkZGl0aW9uYWxQcm9wZXJ0aWVzIjpmYWxzZX1dfSwidWlTY2hlbWEiOnt9LCJ0aGVtZSI6ImRlZmF1bHQiLCJsaXZlU2V0dGluZ3MiOnsic2hvd0Vycm9yTGlzdCI6InRvcCIsImV4cGVyaW1lbnRhbF9kZWZhdWx0Rm9ybVN0YXRlQmVoYXZpb3IiOnsiYXJyYXlNaW5JdGVtcyI6eyJwb3B1bGF0ZSI6InBvcHVsYXRlIiwibWVyZ2VFeHRyYURlZmF1bHRzIjpmYWxzZX0sImFsbE9mIjoic2tpcERlZmF1bHRzIiwiZW1wdHlPYmplY3RGaWVsZHMiOiJwb3B1bGF0ZUFsbERlZmF1bHRzIn0sImxpdmVWYWxpZGF0ZSI6ZmFsc2V9fQ==
Environment
Anything else?
No response
The text was updated successfully, but these errors were encountered: