oneOf + const is handled differently when nested in a property vs as a root object property
#4963 opened on Feb 19, 2026
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?
mantine
Version
6.3.1
Current Behavior
It's possible there's something I don't understand about JSON Schema or RJSF here, but this seems like a bug to me.
This is with the following feature flag:
experimental_defaultFormStateBehavior={{
constAsDefaults: 'always',
}}
The first schema will have the behavior of enforcing food equals "fish" if animal equals "Cat". Even if the user uses the dropdown to select a different value, it forces it back to the const value.
The second schema is essentially the same schema, except nested inside a property nested. The above behavior is no longer observed.
Validation is not broken, but the UX behavior changes.
Working playground with the schema below:
{
"type": "object",
"properties": {
"animal": {
"enum": [
"Cat",
"Fish"
]
},
"food": {
"type": "string",
"enum": [
"meat",
"grass",
"fish"
]
}
},
"allOf": [
{
"if": {
"properties": {
"animal": {
"const": "Cat"
}
}
},
"then": {
"properties": {
"food": {
"const": "fish"
}
},
"required": [
"food"
]
}
},
{
"required": [
"animal"
]
}
]
}
Bugged playground with the schema below:
{
"type": "object",
"properties": {
"nested": {
"type": "object",
"properties": {
"animal": {
"enum": [
"Cat",
"Fish"
]
},
"food": {
"type": "string",
"enum": [
"meat",
"grass",
"fish"
]
},
"allOf": [
{
"if": {
"properties": {
"animal": {
"const": "Cat"
}
}
},
"then": {
"properties": {
"food": {
"const": "fish"
}
},
"required": [
"food"
]
}
},
{
"required": [
"animal"
]
}
]
}
}
}
}
Expected Behavior
Consistent UX behavior whether the allOf is the root object or a nested object property.
Steps To Reproduce
Observable in the plaground via the two links above
Environment
- OS: Windows 11
- Node: 22.13.1
- npm: 11.7.0
Anything else?
No response