Closed chillleader closed 6 months ago
I can reproduce this bug. Root cause is this line, where we check if the condition has an equals
.
The Code only checks if equals
has a truthy value, rather than if the property exists. This blocks use-cases like checking for "false" or "undefined". We should therefore use condition.hasOwnProperty('equals')
here.
When implementing, I noticed that initially, the value will be ''
(empty string) instead of false
. To ensure the conditional property is displayed on the first render, you need to add a default value to it:
{
"id": "myBooleanProp",
"type": "Boolean",
"label": "Checkbox",
"binding": {
"type": "zeebe:property",
"name": "myBooleanProp"
},
"value": false
},
I'll go ahead with the identified fix and open a follow-up issue to decide if we always want to persist "false" by default
Released v1.15.2
with the fix.
Describe the Bug
Boolean properties behave inconsistently when it comes to referencing them in conditions:
true
, it works as expectedfalse
, nothing happensfalse
(checkbox not active), however, the default element template value is""
(empty string).Steps to Reproduce
Element template
```json { "$schema": "https://unpkg.com/@camunda/zeebe-element-templates-json-schema/resources/schema.json", "name": "Boolean prop bug demo", "id": "9741b537-6b04-4540-9fbc-e136dcbcb5bc", "version": 1713266932057, "appliesTo": [ "bpmn:Task" ], "properties": [ { "id": "myBooleanProp", "type": "Boolean", "label": "Checkbox", "binding": { "type": "zeebe:property", "name": "myBooleanProp" } }, { "id": "inputForActiveCheckbox", "type": "String", "label": "Input that appears when checkbox is ACTIVE", "binding": { "type": "zeebe:property", "name": "inputActive" }, "condition": { "property": "myBooleanProp", "equals": true } }, { "id": "inputForInactiveCheckbox", "type": "String", "label": "Input that appears when checkbox is INACTIVE", "binding": { "type": "zeebe:property", "name": "inputInactive" }, "condition": { "property": "myBooleanProp", "equals": false } } ] } ```inputForActiveCheckbox
is added when the checkbox is active, however when it's not active,inputForInactiveCheckbox
is not added.Expected Behavior
false
should work as expectedfalse
unless specified otherwise to be consistent with the UI representationEnvironment