mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-20 12:23:02 +00:00
fix(ComboBox): selectedIndex prog. setting on filtered items
This commit is contained in:
parent
8264366473
commit
e00ee66cf5
1 changed files with 7 additions and 8 deletions
|
@ -138,6 +138,7 @@
|
|||
ref?.focus();
|
||||
}
|
||||
|
||||
let prevInputValue;
|
||||
afterUpdate(() => {
|
||||
if (open) {
|
||||
ref.focus();
|
||||
|
@ -163,15 +164,10 @@
|
|||
selectedItem = filteredItems[0];
|
||||
highlightedIndex = -1;
|
||||
highlightedId = undefined;
|
||||
} else {
|
||||
if (filteredItems?.length === 1) {
|
||||
selectedId = filteredItems[0].id;
|
||||
selectedItem = filteredItems[0];
|
||||
} else {
|
||||
selectedId = items[selectedIndex].id;
|
||||
selectedItem = items[selectedIndex];
|
||||
}
|
||||
}
|
||||
dispatch("select", { selectedId, selectedIndex, selectedItem });
|
||||
}
|
||||
|
||||
|
@ -268,8 +264,8 @@
|
|||
inputValue = filteredItems[selectedIndex].text;
|
||||
selectedItem = filteredItems[selectedIndex];
|
||||
selectedId = filteredItems[selectedIndex].id;
|
||||
} else {
|
||||
}
|
||||
selectedIndex = items.findIndex((item) => item.id === selectedId);
|
||||
} else {
|
||||
selectedIndex = 0;
|
||||
open = false;
|
||||
|
@ -278,6 +274,9 @@
|
|||
inputValue = filteredItems[selectedIndex].text;
|
||||
selectedItem = filteredItems[selectedIndex];
|
||||
selectedId = filteredItems[selectedIndex].id;
|
||||
selectedIndex = items.findIndex(
|
||||
(item) => item.id === selectedId
|
||||
);
|
||||
}
|
||||
}
|
||||
} else if (key === 'Tab') {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue