From 93317fc5dee4ec4eaf70682d78452d803c86594e Mon Sep 17 00:00:00 2001 From: metonym Date: Wed, 12 Jan 2022 15:48:06 -1000 Subject: [PATCH] feat(combo-box): add option to clear accessor to not re-focus input Closes #994 --- src/ComboBox/ComboBox.svelte | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ComboBox/ComboBox.svelte b/src/ComboBox/ComboBox.svelte index 2486a72e..9576206d 100644 --- a/src/ComboBox/ComboBox.svelte +++ b/src/ComboBox/ComboBox.svelte @@ -126,9 +126,9 @@ /** * Clear the combo box programmatically - * @type {() => void} + * @type {(options?: { focus?: boolean; }) => void} */ - export function clear() { + export function clear(options = {}) { prevSelectedIndex = undefined; selectedIndex = -1; highlightedIndex = -1; @@ -137,7 +137,7 @@ selectedItem = undefined; open = false; inputValue = ""; - ref?.focus(); + if (options?.focus !== false) ref?.focus(); } afterUpdate(() => {