mirror of
https://github.com/immich-app/immich.git
synced 2024-12-26 10:50:29 +02:00
fix(web): remove query parameter when clearing search (#8817)
fix: remove query parameter when clearing search
This commit is contained in:
parent
f959f2de85
commit
7ce1662b05
@ -1,3 +1,12 @@
|
||||
import { goto } from '$app/navigation';
|
||||
|
||||
export const isExternalUrl = (url: string): boolean => {
|
||||
return new URL(url, window.location.href).origin !== window.location.origin;
|
||||
};
|
||||
|
||||
export const clearQueryParam = async (queryParam: string, url: URL) => {
|
||||
if (url.searchParams.has(queryParam)) {
|
||||
url.searchParams.delete(queryParam);
|
||||
await goto(url);
|
||||
}
|
||||
};
|
||||
|
@ -40,6 +40,7 @@
|
||||
import { onMount } from 'svelte';
|
||||
import type { PageData } from './$types';
|
||||
import { locale } from '$lib/stores/preferences.store';
|
||||
import { clearQueryParam } from '$lib/utils/navigation';
|
||||
|
||||
export let data: PageData;
|
||||
|
||||
@ -279,10 +280,7 @@
|
||||
|
||||
const handleSearchPeople = async (force: boolean) => {
|
||||
if (searchName === '') {
|
||||
if ($page.url.searchParams.has(QueryParameter.SEARCHED_PEOPLE)) {
|
||||
$page.url.searchParams.delete(QueryParameter.SEARCHED_PEOPLE);
|
||||
await goto($page.url);
|
||||
}
|
||||
await clearQueryParam(QueryParameter.SEARCHED_PEOPLE, $page.url);
|
||||
return;
|
||||
}
|
||||
if (!force && people.length < maximumLengthSearchPeople && searchName.startsWith(searchWord)) {
|
||||
@ -393,6 +391,11 @@
|
||||
handleError(error, 'Unable to save name');
|
||||
}
|
||||
};
|
||||
|
||||
const onResetSearchBar = async () => {
|
||||
searchedPeople = [];
|
||||
await clearQueryParam(QueryParameter.SEARCHED_PEOPLE, $page.url);
|
||||
};
|
||||
</script>
|
||||
|
||||
<svelte:window bind:innerHeight use:shortcut={{ shortcut: { key: 'Escape' }, onShortcut: handleCloseClick }} />
|
||||
@ -421,9 +424,7 @@
|
||||
bind:name={searchName}
|
||||
isSearching={isSearchingPeople}
|
||||
placeholder="Search people"
|
||||
on:reset={() => {
|
||||
searchedPeople = [];
|
||||
}}
|
||||
on:reset={onResetSearchBar}
|
||||
on:search={({ detail }) => handleSearch(detail.force ?? false)}
|
||||
/>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user