mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-20 12:23:02 +00:00
fix(multiselect): do not mutate sortedItems
This commit is contained in:
parent
f6c9c8cea1
commit
6f9dddbcc0
1 changed files with 8 additions and 6 deletions
|
@ -329,9 +329,10 @@
|
||||||
change(-1);
|
change(-1);
|
||||||
} else if (key === 'Enter') {
|
} else if (key === 'Enter') {
|
||||||
if (highlightedIndex > -1) {
|
if (highlightedIndex > -1) {
|
||||||
sortedItems[highlightedIndex].checked = !sortedItems[
|
sortedItems = sortedItems.map((item, i) => {
|
||||||
highlightedIndex
|
if (i !== highlightedIndex) return item;
|
||||||
].checked;
|
return { ...item, checked: !item.checked };
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}}"
|
}}"
|
||||||
|
@ -403,9 +404,10 @@
|
||||||
return { ...item, checked: !item.checked };
|
return { ...item, checked: !item.checked };
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
sortedItems[highlightedIndex].checked = !sortedItems[
|
sortedItems = sortedItems.map((item, i) => {
|
||||||
highlightedIndex
|
if (i !== highlightedIndex) return item;
|
||||||
].checked;
|
return { ...item, checked: !item.checked };
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (key === 'Tab') {
|
} else if (key === 'Tab') {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue