Prerequisites
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
Prerequisites
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:
The first schema will have the behavior of enforcing
foodequals"fish"ifanimalequals"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:
Bugged playground with the schema below:
Expected Behavior
Consistent UX behavior whether the
allOfis the root object or a nested object property.Steps To Reproduce
Observable in the plaground via the two links above
Environment
Anything else?
No response