Toggles now wont apply tag targeting if deactivated

This commit is contained in:
Stefan Zermatten
2023-08-24 12:09:14 +02:00
parent 0df7763366
commit 1778111c75

View File

@@ -5,8 +5,26 @@ export default function evaluateToggles(computation, node) {
if (!toggles) return;
toggles.forEach(toggle => {
if (
(!toggle.enabled && !toggle.disabled && toggle.condition && !toggle.condition.value)
|| (toggle.disabled)
(
// Toggle isn't set to constantly enabled or disabled
!toggle.enabled &&
!toggle.disabled &&
// Toggle is not disabled by another toggle targeting it
// Ancestor toggles would've handled this child anyway,
// and tag targeted toggles break the link
!toggle.deactivatedByToggle &&
!toggle.deactivatedByAncestor &&
// Toggle has a condition with a falsy value
toggle.condition &&
!toggle.condition.value
)
|| (
// Toggle is disabled manually
toggle.disabled &&
// Toggle isn't deactivated by something else
!toggle.deactivatedByToggle &&
!toggle.deactivatedByAncestor
)
) {
prop.inactive = true;
prop.deactivatedByToggle = true;