Simplify logic for determine default visibility for a conditional UI component
This commit is contained in:
parent
118141aca2
commit
caccba8fd8
|
@ -159,20 +159,17 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default visible to false if there is a show condition
|
// Default visible to false if there is a show condition
|
||||||
let nextVisible = true
|
let nextVisible = !conditions.find(condition => condition.action === "show")
|
||||||
for (let condition of conditions) {
|
|
||||||
if (condition.action === "show") {
|
|
||||||
nextVisible = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Execute conditions and determine settings and visibility changes
|
||||||
const activeConditions = getActiveConditions(conditions)
|
const activeConditions = getActiveConditions(conditions)
|
||||||
const result = reduceConditionActions(activeConditions)
|
const result = reduceConditionActions(activeConditions)
|
||||||
conditionalSettings = result.settingUpdates
|
|
||||||
if (result.visible != null) {
|
if (result.visible != null) {
|
||||||
nextVisible = result.visible
|
nextVisible = result.visible
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update state from condition results
|
||||||
|
conditionalSettings = result.settingUpdates
|
||||||
visible = nextVisible
|
visible = nextVisible
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue