Skip to content

Commit

Permalink
fix(web): infinite loop browser navigation crash admin settings page (#…
Browse files Browse the repository at this point in the history
…14850)

* fix(web): infinite loop browser navigation crash admin settings page

* pr feedback
  • Loading branch information
alextran1502 authored Dec 21, 2024
1 parent d5906c2 commit 6080e6e
Showing 1 changed file with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 !== ''));
Expand All @@ -26,17 +26,16 @@
let { queryParam, state = writable(getParamValues(queryParam)), children }: Props = $props();
setAccordionState(state);
const searchParams = new URLSearchParams(page.url.searchParams);
$effect(() => {
if (queryParam && $state) {
const searchParams = new URLSearchParams(page.url.searchParams);
if ($state.size > 0) {
searchParams.set(queryParam, [...$state].join(' '));
} else {
searchParams.delete(queryParam);
}
handlePromiseError(goto(`?${searchParams.toString()}`, { replaceState: true, noScroll: true, keepFocus: true }));
if ($state.size > 0) {
searchParams.set(queryParam, [...$state].join(' '));
} else {
searchParams.delete(queryParam);
}
handlePromiseError(goto(`?${searchParams.toString()}`, { replaceState: true, noScroll: true, keepFocus: true }));
});
</script>

Expand Down

0 comments on commit 6080e6e

Please sign in to comment.