mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-14 18:01:06 +00:00
fix(multi-select): fix keyboard navigation for disabled items
Fixes #2128
This commit is contained in:
parent
c67e095eaf
commit
c83f3debb5
1 changed files with 6 additions and 5 deletions
|
@ -201,7 +201,8 @@
|
|||
|
||||
function change(direction) {
|
||||
let index = highlightedIndex + direction;
|
||||
const length = filterable ? filteredItems.length : items.length;
|
||||
const itemsToUse = filterable ? filteredItems : sortedItems;
|
||||
const length = itemsToUse.length;
|
||||
if (length === 0) return;
|
||||
if (index < 0) {
|
||||
index = length - 1;
|
||||
|
@ -209,18 +210,18 @@
|
|||
index = 0;
|
||||
}
|
||||
|
||||
let disabled = items[index].disabled;
|
||||
let disabled = itemsToUse[index].disabled;
|
||||
|
||||
while (disabled) {
|
||||
index = index + direction;
|
||||
|
||||
if (index < 0) {
|
||||
index = items.length - 1;
|
||||
} else if (index >= items.length) {
|
||||
index = length - 1;
|
||||
} else if (index >= length) {
|
||||
index = 0;
|
||||
}
|
||||
|
||||
disabled = items[index].disabled;
|
||||
disabled = itemsToUse[index].disabled;
|
||||
}
|
||||
|
||||
highlightedIndex = index;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue