selecting all iteratively instead or recursively

This commit is contained in:
Assunta DeSanto
2023-05-03 14:23:28 -04:00
parent f35ce17e33
commit c2df1817a0
@@ -61,20 +61,13 @@ function selectAll(selected: boolean) {
const newValue: string[] = [];
if (selected) {
props.options.forEach((option) => {
selectRecursively(option, newValue);
if (option.value) {
newValue.push(option.value);
}
});
}
emit("input", newValue.length === 0 ? null : newValue);
}
function selectRecursively(option: Option, currentValue: string[]) {
currentValue.push(option.value);
if (option.options.length > 0) {
option.options.forEach((option) => {
selectRecursively(option, currentValue);
});
}
}
</script>
<template>