Skip to content

Commit

Permalink
Fix value conditions not correctly applying filters on chained elements
Browse files Browse the repository at this point in the history
  • Loading branch information
bennothommo committed Nov 12, 2024
1 parent b7aacd8 commit 79eb0e9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion modules/system/assets/js/build/system.debug.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion modules/system/assets/js/build/system.js

Large diffs are not rendered by default.

16 changes: 6 additions & 10 deletions modules/system/assets/js/snowboard/extras/Trigger.js
Original file line number Diff line number Diff line change
Expand Up @@ -539,29 +539,25 @@ export default class Trigger extends PluginBase {
testElements.forEach((element) => {
if (element.matches('input[type=checkbox], input[type=radio]')) {
if (element.checked) {
elementValues.add(element, element.value);
elementValues.set(element, element.value);
}
return;
}

elementValues.add(element, element.value);
elementValues.set(element, element.value);
});

// Check if condition is met
let met = false;

if (all) {
met = values.every((value) => elementValues.values().has(value));
}

met = values.some((value) => elementValues.values().has(value));
const met = (all)
? values.every((value) => elementValues.values().find((elementValue) => elementValue === value))
: values.some((value) => elementValues.values().find((elementValue) => elementValue === value));

if (!met) {
return false;
}

// Return only elements who met the condition
return Array.from(elementValues.entries().filter(([, value]) => values.includes(value)).keys());
return Array.from(elementValues.entries().filter(([, value]) => values.includes(value)).map(([, element]) => element));
};
}

Expand Down

0 comments on commit 79eb0e9

Please sign in to comment.