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
A oneOf schema with two objects with the same property but different read-only, default values won't correctly select the option with the matching value for the key when passed a formData, and instead will match the first option with the correct property keys (both the property keys are the same).
Steps to Reproduce
In this playground example, you can see that the two oneOf options both have the same properties (one "lorem" key), with different read-only, default values.
2. If you select the second option, it will update formData to { "lorem": "second" }. If you select the first option, formData becomes { "lorem": "first" }. This is the expected behavior.
3. If you now change formData to { "lorem": "second" }, it will keep the selector on the first option, but change the name to "second".
Expected behavior
Per the example above, I'm trying to initialize the selector on the second option using the formData value.
I have data objects with the same keys but different default, read-only values that represent different options. I want to be able to initialize the selector at the correct option based on the formData passed in.
Actual behavior
The isValid check inside the getMatchingOption method in utils will return true when comparing the following schema:
Even though the it's a default, read-only value and the values don't match.
Version
"@rjsf/core": "^2.4.0"
The text was updated successfully, but these errors were encountered:
zmagauina-fn
changed the title
oneOf schema not selecting correct option for objects with the same property keys but different default, read-only values
oneOf not selecting correct option for objects with the same property keys but different default, read-only values
Sep 24, 2020
Prerequisites
Description
A oneOf schema with two objects with the same property but different read-only, default values won't correctly select the option with the matching value for the key when passed a formData, and instead will match the first option with the correct property keys (both the property keys are the same).
Steps to Reproduce
In this playground example, you can see that the two oneOf options both have the same properties (one "lorem" key), with different read-only, default values.
2. If you select the second option, it will update formData to
{ "lorem": "second" }
. If you select the first option, formData becomes{ "lorem": "first" }
. This is the expected behavior.3. If you now change formData to
{ "lorem": "second" }
, it will keep the selector on the first option, but change the name to "second".Expected behavior
Per the example above, I'm trying to initialize the selector on the second option using the formData value.
I have data objects with the same keys but different default, read-only values that represent different options. I want to be able to initialize the selector at the correct option based on the formData passed in.
Actual behavior
The
isValid
check inside thegetMatchingOption
method inutils
will return true when comparing the following schema:and formData:
Even though the it's a default, read-only value and the values don't match.
Version
The text was updated successfully, but these errors were encountered: