react-jsonschema-form
react-jsonschema-form copied to clipboard
Incorrect merge of anyOf with schemaDependencies in arrays
Prerequisites
- [X] I have searched the existing issues
- [X] I understand that providing a SSCCE example is tremendously useful to the maintainers.
- [X] I have read the documentation
- [X] Ideally, I'm providing a sample JSFiddle or a shared playground link demonstrating the issue.
What theme are you using?
core
Version
5.x
Current Behavior
schema dependencies when used with oneOf and in array incorrectly merges all properties when the depended on field changes.
Apologies if not clear, it's kind of tough to describe. The reproducer should help
Expected Behavior
I would expect only one of the properties to be shown depending on the number of pets.
Steps To Reproduce
- Visit Playground link
- click + to add a person
- for
Do you have any pets
, selectYes: One
- for
How old is your pet?*
, enter some number, e.g.5
- then select
Yes: More than one
- for
Do you want to get rid of any?*
select either of the options, e.g.true
- check the
formData
which now contains both properties-
Do you want to get rid of any?
-
How old is your pet?
-
formData = {
"Do you have any pets?": "Yes: More than one",
"Do you want to get rid of any?": true,
"How old is your pet?": 5
}
Environment
- OS:
- Node:
- npm:
Playground (all)
Anything else?
No response
@skfarhat This is an interesting bug. While it is true that for simple anyOf/oneOf the unnecessary data gets properly removed (as of beta.18 anyway), but the logic that does that doesn't understand dependencies. As a work around, you can pass true for liveOmit
and omitExtraData
to get the result you want as you can see in this playground
This issue has been automatically marked as possibly close because it has not had recent activity. It will be closed if no further activity occurs. Please leave a comment if this is still an issue for you. Thank you.
This issue was closed because of lack of recent activity. Reopen if you still need assistance.