diff --git a/src/Dropdown/Dropdown.svelte b/src/Dropdown/Dropdown.svelte index 52cb6acc..80ba0a47 100644 --- a/src/Dropdown/Dropdown.svelte +++ b/src/Dropdown/Dropdown.svelte @@ -113,6 +113,7 @@ * @typedef {{ id: DropdownItemId; text: DropdownItemText; }} DropdownItem */ + import { createEventDispatcher } from "svelte"; import WarningFilled16 from "carbon-icons-svelte/lib/WarningFilled16"; import { ListBox, @@ -121,6 +122,8 @@ ListBoxMenuItem, } from "../ListBox"; + const dispatch = createEventDispatcher(); + let selectedId = undefined; let highlightedIndex = -1; @@ -136,6 +139,9 @@ highlightedIndex = index; } + $: if (selectedIndex > -1) { + dispatch("select", { selectedId, selectedIndex, selectedItem }); + } $: inline = type === "inline"; $: selectedItem = items[selectedIndex]; $: if (!open) { @@ -143,7 +149,7 @@ } -