From afb88394c7bdbc2a5d9ab271b7d25b6129cf03fd Mon Sep 17 00:00:00 2001 From: Eric Liu Date: Sat, 5 Dec 2020 10:30:53 -0800 Subject: [PATCH] fix(combo-box): selecting a different combobox should focus the input --- src/ComboBox/ComboBox.svelte | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/ComboBox/ComboBox.svelte b/src/ComboBox/ComboBox.svelte index c6ab6d32..1d1e4f87 100644 --- a/src/ComboBox/ComboBox.svelte +++ b/src/ComboBox/ComboBox.svelte @@ -82,7 +82,7 @@ */ export let listRef = null; - import { createEventDispatcher, afterUpdate } from "svelte"; + import { createEventDispatcher, afterUpdate, tick } from "svelte"; import WarningFilled16 from "carbon-icons-svelte/lib/WarningFilled16"; import { ListBox, @@ -173,9 +173,11 @@ { if (disabled) return; open = true; + await tick(); + ref.focus(); }}" id="{id}" name="{name}" @@ -220,6 +222,7 @@ on:focus on:blur on:blur="{({ relatedTarget }) => { + if (!open) return; if (relatedTarget && relatedTarget.getAttribute('role') !== 'button') { ref.focus(); }