-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Open
Labels
bugneeds triageInitial label given, to be assigned correct labels and assignedInitial label given, to be assigned correct labels and assigned
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
6.0.0-beta.12
Current Behavior
When using discriminated unions (oneOf/anyOf) with boolean properties that exist across multiple schema variants, switching between union options incorrectly sets undefined/missing boolean values to empty objects {}
.
Specifically:
- Form has an optional boolean field that is missing or undefined
- User switches from Schema Variant A to Schema Variant B
- The boolean field gets set to
{}
instead of remainingundefined
or getting a proper boolean default - This breaks form validation and data integrity
Note: Existing boolean values (true/false) are preserved correctly - the bug only affects undefined/missing boolean fields.
Expected Behavior
Boolean fields that exist in multiple discriminated union variants should remain undefined
or get proper default boolean values when switching between schema options, not get set to empty objects {}
.
Steps To Reproduce
Exact Steps:
- Add an array item (click the "+" button)
- Change the array type (use the dropdown to switch between typeA and typeB)
- Notice the validation errors and
showField
set to{}
instead of boolean - Error message shows: "showField must be boolean" but the field contains
{}
Minimal Reproduction Schema
{
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"oneOf": [
{
"type": "object",
"properties": {
"type": { "const": "typeA" },
"showField": { "type": "boolean" },
"dataA": { "type": "string" }
}
},
{
"type": "object",
"properties": {
"type": { "const": "typeB" },
"showField": { "type": "boolean" },
"dataB": { "type": "string" }
}
}
]
}
}
}
}
Form Data (initially empty):
{
"items": []
}
Steps:
- Leave
showField
undefined (don't set any value) - Switch union selector from "typeA" to "typeB"
showField
gets set to{}
instead of remainingundefined
Environment
- OS: MacOS
- Node: 22
- npm: 10
Anything else?
No response
Metadata
Metadata
Assignees
Labels
bugneeds triageInitial label given, to be assigned correct labels and assignedInitial label given, to be assigned correct labels and assigned