From 35a97920aa1e4be779644af464017fc9cc4b694a Mon Sep 17 00:00:00 2001 From: JovannMC Date: Wed, 28 May 2025 22:14:40 +0300 Subject: [PATCH] feat: focus when opening dropdown --- .../functional/FormatDropdown.svelte | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/lib/components/functional/FormatDropdown.svelte b/src/lib/components/functional/FormatDropdown.svelte index 21815d2..94a2935 100644 --- a/src/lib/components/functional/FormatDropdown.svelte +++ b/src/lib/components/functional/FormatDropdown.svelte @@ -216,6 +216,23 @@ } }; + const clickDropdown = () => { + open = !open; + if (open) { + setTimeout(() => { + if (dropdownMenu) { + const searchInput = dropdownMenu.querySelector( + "#format-search", + ) as HTMLInputElement; + if (searchInput) { + searchInput.focus(); + searchInput.select(); + } + } + }, 0); // let dropdown open first + } + }; + onMount(() => { const handleClickOutside = (e: MouseEvent) => { if (dropdown && !dropdown.contains(e.target as Node)) { @@ -248,10 +265,9 @@ bind:this={dropdown} >