mirror of
https://github.com/immich-app/immich.git
synced 2025-05-24 01:12:58 -04:00
fix(web): search bar deactivates when focus exits (#17549)
* fix(web): search bar deactivates when focus exits * fix: disable search bar on destroy For example, on the search page. If the escape key is pressed while the advanced filters button is focused, the search page will close but the search bar will remain activated.
This commit is contained in:
parent
983f656a6b
commit
79d4ce2d6d
@ -13,7 +13,7 @@
|
||||
import CircleIconButton from '$lib/components/elements/buttons/circle-icon-button.svelte';
|
||||
import { t } from 'svelte-i18n';
|
||||
import { generateId } from '$lib/utils/generate-id';
|
||||
import { tick } from 'svelte';
|
||||
import { onDestroy, tick } from 'svelte';
|
||||
|
||||
interface Props {
|
||||
value?: string;
|
||||
@ -35,6 +35,10 @@
|
||||
|
||||
const listboxId = generateId();
|
||||
|
||||
onDestroy(() => {
|
||||
searchStore.isSearchEnabled = false;
|
||||
});
|
||||
|
||||
const handleSearch = async (payload: SmartSearchDto | MetadataSearchDto) => {
|
||||
const params = getMetadataSearchQuery(payload);
|
||||
|
||||
@ -70,17 +74,7 @@
|
||||
};
|
||||
|
||||
const onFocusOut = () => {
|
||||
const focusOutTimer = setTimeout(() => {
|
||||
if (searchStore.isSearchEnabled) {
|
||||
searchStore.preventRaceConditionSearchBar = true;
|
||||
}
|
||||
|
||||
closeDropdown();
|
||||
searchStore.isSearchEnabled = false;
|
||||
showFilter = false;
|
||||
}, 100);
|
||||
|
||||
clearTimeout(focusOutTimer);
|
||||
searchStore.isSearchEnabled = false;
|
||||
};
|
||||
|
||||
const onHistoryTermClick = async (searchTerm: string) => {
|
||||
|
@ -1,12 +1,10 @@
|
||||
class SearchStore {
|
||||
savedSearchTerms = $state<string[]>([]);
|
||||
isSearchEnabled = $state(false);
|
||||
preventRaceConditionSearchBar = $state(false);
|
||||
|
||||
clearCache() {
|
||||
this.savedSearchTerms = [];
|
||||
this.isSearchEnabled = false;
|
||||
this.preventRaceConditionSearchBar = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,6 @@
|
||||
import SearchBar from '$lib/components/shared-components/search-bar/search-bar.svelte';
|
||||
import { AppRoute, QueryParameter } from '$lib/constants';
|
||||
import { assetViewingStore } from '$lib/stores/asset-viewing.store';
|
||||
import { searchStore } from '$lib/stores/search.svelte';
|
||||
import { shortcut } from '$lib/actions/shortcut';
|
||||
import {
|
||||
type AlbumResponseDto,
|
||||
@ -88,10 +87,7 @@
|
||||
assetInteraction.selectedAssets = [];
|
||||
return;
|
||||
}
|
||||
if (!searchStore.preventRaceConditionSearchBar) {
|
||||
handlePromiseError(goto(previousRoute));
|
||||
}
|
||||
searchStore.preventRaceConditionSearchBar = false;
|
||||
handlePromiseError(goto(previousRoute));
|
||||
};
|
||||
|
||||
$effect(() => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user