From 8a941556cb9acf1a6523a91cc739811027fdb857 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Ml=C3=A1dek?= Date: Sat, 13 Jul 2024 21:06:07 +0200 Subject: [PATCH] feat(webui): Selector chooses first option on unfocus if primitive --- webui/src/lib/components/utils/Selector.svelte | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/webui/src/lib/components/utils/Selector.svelte b/webui/src/lib/components/utils/Selector.svelte index 4b2ab7a..dfe7777 100644 --- a/webui/src/lib/components/utils/Selector.svelte +++ b/webui/src/lib/components/utils/Selector.svelte @@ -312,6 +312,20 @@ } } + $: onFocusChange(inputFocused); + + function onFocusChange(focused: boolean) { + if (!focused) { + if ( + options.length && + inputValue && + ['String', 'Number', 'Attribute'].includes(options[0].t) + ) { + set(options[0]); + } + } + } + let addressToLabels: { [key: string]: string[] } = {}; function onAddressResolved(address: string, ev: CustomEvent) { addressToLabels[address] = ev.detail;