Visible If not working if value is [0]
AleksaDursun opened this issue · comments
When my selectField
value is 0 the schema does not render the fields that have visibleIf: {selectField: [0]}
.
This is the code in my schema.
{ type: 'array', title: 'Columns', items: { type: 'object', properties: { color: { type: 'string', description: 'Color', widget: 'color-picker', } }, }, visibleIf: { selectField: [0] }, }
A working example on Stackblitz (click) for your schema:
{
"type": "object",
"properties": {
"selectField": {
"type": "string",
"widget": "select",
"oneOf": [
{
"enum": ["0"],
"description": "Zero"
},
{
"enum": ["1"],
"description": "One"
}
]
},
"columns": {
"type": "array",
"title": "Columns",
"items": {
"type": "object",
"properties": {
"color": {
"type": "string",
"description": "Color",
"widget": "color-picker"
}
}
},
"visibleIf": {
"selectField": [0]
}
}
}
}
@AleksaDursun would you take a look on it?
That is the workaround I found as well, but the issue still persists. If the value is equal to 0 (number zero) it does not work.
Got the same problem.
As far as I can tell it's related to this line:
The truth value of variable value
is false if it is equal to the number 0 and double negation still makes it false. This is probably to check if there is no null
or undefined
in the variable value
but this also makes the values NaN
, number 0, boolean false and empty string ''
to not pass this check.
My workaround is to use "$EXP$ target.value == 0"