diff --git a/src/lib/components/Searchbar.svelte b/src/lib/components/Searchbar.svelte index e7964f79..a16b511c 100644 --- a/src/lib/components/Searchbar.svelte +++ b/src/lib/components/Searchbar.svelte @@ -4,6 +4,7 @@ import Search from "lucide-svelte/icons/search"; import { goto } from "$app/navigation"; import { Combobox } from "bits-ui"; + import { tick } from "svelte"; let searchHistory = []; let updatedSearchHistory = []; @@ -154,6 +155,7 @@ async function search() { isLoading = true; + clearTimeout(timeoutId); // Clear any existing timeout if (!inputValue.trim()) { @@ -229,6 +231,7 @@ $: { if (searchBarModalChecked === true && typeof window !== "undefined") { + console.log("open"); if ($screenWidth > 640) { inputElement.focus(); } @@ -277,6 +280,17 @@ search(); } } + + $: if (showSuggestions && searchBarData?.length && touchedInput) { + tick().then(() => { + const input = document.getElementById("combobox-input"); + if (input) { + input.dispatchEvent( + new KeyboardEvent("keydown", { key: "ArrowDown", bubbles: true }), + ); + } + }); + }