mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-20 12:23:02 +00:00
fix: dispatching filteredItems
This commit is contained in:
parent
c8fe0b992b
commit
89ddf6549b
1 changed files with 9 additions and 2 deletions
|
@ -150,8 +150,15 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
$: if (selectedIndex > -1) {
|
$: if (selectedIndex > -1) {
|
||||||
selectedId = items[selectedIndex].id;
|
let _selectedItem;
|
||||||
dispatch("select", { selectedId, selectedIndex, selectedItem });
|
if (filteredItems?.length === 1) {
|
||||||
|
selectedId = filteredItems[0].id;
|
||||||
|
_selectedItem = filteredItems[0];
|
||||||
|
} else {
|
||||||
|
selectedId = items[selectedIndex].id;
|
||||||
|
_selectedItem = selectedItem;
|
||||||
|
}
|
||||||
|
dispatch("select", { selectedId, selectedIndex, selectedItem: _selectedItem });
|
||||||
}
|
}
|
||||||
$: ariaLabel = $$props["aria-label"] || "Choose an item";
|
$: ariaLabel = $$props["aria-label"] || "Choose an item";
|
||||||
$: menuId = `menu-${id}`;
|
$: menuId = `menu-${id}`;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue