From dee3a0bf3b9dd043c1a8e97f7a9e1b2e4db19f2e Mon Sep 17 00:00:00 2001 From: JovannMC Date: Wed, 28 May 2025 22:16:28 +0300 Subject: [PATCH] feat: enter to select first format --- src/lib/components/functional/FormatDropdown.svelte | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/lib/components/functional/FormatDropdown.svelte b/src/lib/components/functional/FormatDropdown.svelte index 94a2935..f73a5df 100644 --- a/src/lib/components/functional/FormatDropdown.svelte +++ b/src/lib/components/functional/FormatDropdown.svelte @@ -233,6 +233,15 @@ } }; + const onEnter = (event: KeyboardEvent) => { + if (event.key === "Enter") { + event.preventDefault(); + if (filteredData.formats.length > 0) { + selectOption(filteredData.formats[0]); + } + } + }; + onMount(() => { const handleClickOutside = (e: MouseEvent) => { if (dropdown && !dropdown.contains(e.target as Node)) { @@ -326,6 +335,7 @@ class="flex-grow w-full !pl-11 !pr-3 rounded-lg bg-panel text-foreground" bind:value={searchQuery} oninput={handleSearch} + onkeydown={onEnter} onfocus={() => {}} id="format-search" autocomplete="off"