fix: reactivity warnings in searchbox

This commit is contained in:
midzelis 2025-09-26 22:58:04 +00:00
parent 5ac5aa57a8
commit 8943242b7f

View file

@ -33,9 +33,13 @@
let isFocus = $state(false); let isFocus = $state(false);
let close: (() => Promise<void>) | undefined; let close: (() => Promise<void>) | undefined;
let navigating = false;
const listboxId = generateId(); const listboxId = generateId();
onDestroy(() => { onDestroy(() => {
if (navigating) {
return;
}
searchStore.isSearchEnabled = false; searchStore.isSearchEnabled = false;
}); });
@ -44,6 +48,7 @@
closeDropdown(); closeDropdown();
searchStore.isSearchEnabled = false; searchStore.isSearchEnabled = false;
navigating = true;
await goto(`${AppRoute.SEARCH}?${params}`); await goto(`${AppRoute.SEARCH}?${params}`);
}; };
@ -73,6 +78,9 @@
}; };
const onFocusOut = () => { const onFocusOut = () => {
if (navigating) {
return;
}
searchStore.isSearchEnabled = false; searchStore.isSearchEnabled = false;
}; };
@ -161,6 +169,9 @@
}; };
const closeDropdown = () => { const closeDropdown = () => {
if (navigating) {
return;
}
showSuggestions = false; showSuggestions = false;
isFocus = false; isFocus = false;
searchHistoryBox?.clearSelection(); searchHistoryBox?.clearSelection();