From b0be811d8b6c736dae418b7f5f913b860d30de5d Mon Sep 17 00:00:00 2001 From: Eric Liu Date: Tue, 31 Dec 2019 12:53:34 -0800 Subject: [PATCH] chore(combo-box): initialize inputValue with empty string --- src/components/ComboBox/ComboBox.svelte | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/components/ComboBox/ComboBox.svelte b/src/components/ComboBox/ComboBox.svelte index aec48f2a..99779d14 100644 --- a/src/components/ComboBox/ComboBox.svelte +++ b/src/components/ComboBox/ComboBox.svelte @@ -32,7 +32,7 @@ let selectedId = undefined; let inputRef = undefined; - let inputValue = undefined; + let inputValue = ''; let highlightedIndex = -1; function change(direction) { @@ -57,14 +57,14 @@ } }); - $: selectedItem = items[selectedIndex]; - $: inputValue = selectedItem ? selectedItem.text : undefined; - $: value = inputValue; $: ariaLabel = $$props['aria-label'] || 'Choose an item'; $: menuId = `menu-${id}`; $: comboId = `combo-${id}`; $: highlightedId = items[highlightedIndex] ? items[highlightedIndex].id : undefined; $: filteredItems = items.filter(item => shouldFilterItem(item, value)); + $: selectedItem = items[selectedIndex]; + $: inputValue = selectedItem ? selectedItem.text : undefined; + $: value = inputValue;