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
I have a schema that has anyOf between two options. The form renders a selector for it, but when I use the selector to select the options, it does not work. I also notice when I select the option 2 for example, the formData is filled with default of both option 1 and option 2.
When turning off omitExtraData and liveOmit, it works normally.
Expected Behavior
When I switch to option 2, the fields for option 2 should be rendered, and the formData contains only the default values for option 2
Steps To Reproduce
Visit playground, and try to use the selector to select option 2. You will notice the fields for option 1 still render and the formData includes the default values for both option 1 and option 2
I dug a bit, and it looks like the bug happens like this. Given the schema has a top-level default, which is the value of option 1. Some fields from option 1 and option 2 have default values as well.
When I select option 2:
First onChange happens with the id of the anyOf_select and formData contains the default values for option 2
Then the second change happens without any id and the formData contains the defaults of the top-level defaults and the option 2 defaults. I believe this is because of some internal initialization
Now the formData is mixed between option 1 and option 2 values, and the form thinks option 1 is still selected, hence the bug
I think the expected behaviour should be that either the second onChange does not happen, or it happens in a way that includes only the defaults for the second option.
Prerequisites
What theme are you using?
core
Version
5.x
Current Behavior
I have a schema that has anyOf between two options. The form renders a selector for it, but when I use the selector to select the options, it does not work. I also notice when I select the option 2 for example, the formData is filled with default of both option 1 and option 2.
When turning off omitExtraData and liveOmit, it works normally.
Expected Behavior
When I switch to option 2, the fields for option 2 should be rendered, and the formData contains only the default values for option 2
Steps To Reproduce
Visit playground, and try to use the selector to select option 2. You will notice the fields for option 1 still render and the formData includes the default values for both option 1 and option 2
Environment
Anything else?
The schema I'm testing with
The text was updated successfully, but these errors were encountered: