diff --git a/web/src/lib/components/shared-components/settings/setting-accordion-state.svelte b/web/src/lib/components/shared-components/settings/setting-accordion-state.svelte index 4d97ee5cc6..6b3ae81685 100644 --- a/web/src/lib/components/shared-components/settings/setting-accordion-state.svelte +++ b/web/src/lib/components/shared-components/settings/setting-accordion-state.svelte @@ -9,9 +9,9 @@ import { writable, type Writable } from 'svelte/store'; import { createContext } from '$lib/utils/context'; import { page } from '$app/state'; - import { handlePromiseError } from '$lib/utils'; import { goto } from '$app/navigation'; import type { Snippet } from 'svelte'; + import { handlePromiseError } from '$lib/utils'; const getParamValues = (param: string) => { return new Set((page.url.searchParams.get(param) || '').split(' ').filter((x) => x !== '')); @@ -26,17 +26,16 @@ let { queryParam, state = writable(getParamValues(queryParam)), children }: Props = $props(); setAccordionState(state); - $effect(() => { - if (queryParam && $state) { - const searchParams = new URLSearchParams(page.url.searchParams); - if ($state.size > 0) { - searchParams.set(queryParam, [...$state].join(' ')); - } else { - searchParams.delete(queryParam); - } + const searchParams = new URLSearchParams(page.url.searchParams); - handlePromiseError(goto(`?${searchParams.toString()}`, { replaceState: true, noScroll: true, keepFocus: true })); + $effect(() => { + if ($state.size > 0) { + searchParams.set(queryParam, [...$state].join(' ')); + } else { + searchParams.delete(queryParam); } + + handlePromiseError(goto(`?${searchParams.toString()}`, { replaceState: true, noScroll: true, keepFocus: true })); });