From 1778111c75e235dfd6f23ba48d5ad1e22f635288 Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Thu, 24 Aug 2023 12:09:14 +0200 Subject: [PATCH] Toggles now wont apply tag targeting if deactivated --- .../computeComputation/computeToggles.js | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/app/imports/api/engine/computation/computeComputation/computeToggles.js b/app/imports/api/engine/computation/computeComputation/computeToggles.js index 657305d6..a39e8dc4 100644 --- a/app/imports/api/engine/computation/computeComputation/computeToggles.js +++ b/app/imports/api/engine/computation/computeComputation/computeToggles.js @@ -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;