-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Closed
Labels
Description
Prerequisites
- I have searched the existing issues
- I understand that providing a SSCCE example is tremendously useful to the maintainers.
- I have read the documentation
- Ideally, I'm providing a sample JSFiddle, Codesandbox.io or preferably a shared playground link demonstrating the issue.
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
Playground: https://rjsf-team.github.io/react-jsonschema-form/#eyJmb3JtRGF0YSI6eyJteVByb3BlcnR5Ijp7InZhbHVlX3Byb3ZpZGVyX3R5cGUiOiJUWVBFXzEiLCJzdGFydCI6NjUwMDAwMDAwMCwic3RvcCI6ODUwMDAwMDAwMCwic3RlcF9zaXplIjoxMDAwMDAsIm51bV9zYW1wbGVzIjoyMDAxLCJzd2VlcF9zaGlmdCI6MH19LCJzY2hlbWEiOnsidGl0bGUiOiJTZXR0aW5ncyIsInR5cGUiOiJvYmplY3QiLCJwcm9wZXJ0aWVzIjp7Im15UHJvcGVydHkiOnsiZGVmYXVsdCI6eyJ2YWx1ZV9wcm92aWRlcl90eXBlIjoiVFlQRV8xIiwic3RhcnQiOjY1MDAwMDAwMDAsInN0b3AiOjg1MDAwMDAwMDAsInN0ZXBfc2l6ZSI6MTAwMDAwLCJudW1fc2FtcGxlcyI6MjAwMX0sImFueU9mIjpbeyIkcmVmIjoiIy9kZWZpbml0aW9ucy9UeXBlMiJ9LHsiJHJlZiI6IiMvZGVmaW5pdGlvbnMvVHlwZTEifV19fSwiZGVmaW5pdGlvbnMiOnsiVHlwZTIiOnsidGl0bGUiOiJUeXBlMiIsInR5cGUiOiJvYmplY3QiLCJwcm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YURhdGEiOnRydWUsImxpdmVPbWl0Ijp0cnVlLCJleHBlcmltZW50YWxfZGVmYXVsdEZvcm1TdGF0ZUJlaGF2aW9yIjp7ImFycmF5TWluSXRlbXMiOiJwb3B1bGF0ZSIsImFsbE9mIjoic2tpcERlZmF1bHRzIiwiZW1wdHlPYmplY3RGaWVsZHMiOiJwb3B1bGF0ZUFsbERlZmF1bHRzIiwibWVyZ2VEZWZhdWx0c0ludG9Gb3JtRGF0YSI6InVzZUZvcm1EYXRhSWZQcmVzZW50In0sImxpdmVWYWxpZGF0ZSI6ZmFsc2UsIm5vVmFsaWRhdGUiOmZhbHNlfX0=
Anything else?
The schema I'm testing with
{
"title": "Settings",
"type": "object",
"properties": {
"myProperty": {
"default": {
"value_provider_type": "TYPE_1",
"start": 6500000000,
"stop": 8500000000,
"step_size": 100000,
"num_samples": 2001
},
"anyOf": [
{
"$ref": "#/definitions/Type2"
},
{
"$ref": "#/definitions/Type1"
}
]
}
},
"definitions": {
"Type2": {
"title": "Type2",
"type": "object",
"properties": {
"sweep_range": {
"title": "Sweep range",
"type": "number"
},
"sweep_step_size": {
"title": "Step size",
"type": "number"
},
"sweep_shift": {
"title": "Shift",
"default": 0,
"type": "number"
}
},
"required": [
"sweep_range",
"sweep_step_size"
]
},
"Type1": {
"title": "Type1",
"type": "object",
"properties": {
"start": {
"title": "Start",
"type": "number"
},
"stop": {
"title": "Stop",
"type": "number"
},
"step_size": {
"title": "Step size",
"type": "number"
},
"num_samples": {
"title": "Number of samples",
"type": "integer",
"default": -1
},
"value_provider_type": {
"title": "Value Provider Type",
"default": "TYPE_1",
"enum": [
"TYPE_1"
],
"type": "string"
}
},
"required": [
"start",
"stop",
"value_provider_type"
]
}
}
}