From 960c55e1f38cdabc3e19f6f411dc22a93e21d061 Mon Sep 17 00:00:00 2001 From: Abdellah Ouadoudi Date: Fri, 19 Jun 2026 17:12:34 +0200 Subject: [PATCH] preserve URL filter state on page refresh (#9680) * fix(home): preserve URL filter state on page refresh ListFilters.loadFilterFromUrl() runs synchronously at script init and sets ownerFilter via binding. When $workspaceStore resolves asynchronously after mount it triggered the $effect that resets ownerFilter, wiping the URL-loaded filter before the user saw any results. Skip the first $workspaceStore resolution using the same firstRun guard pattern already used in this file (firstWorkspaceRun). Workspace switches still correctly clear the filter. Fixes #9624 * refactor(home): reset filters on workspace change instead of first-run guard Track the previous workspace value and clear filters only when it actually changes, rather than skipping the first $workspaceStore resolution. Encodes the real invariant (reset on change) without depending on child/parent init ordering, and preserves URL-loaded filters on initial mount by construction. Co-Authored-By: Claude Opus 4.8 (1M context) --------- Co-authored-by: Ruben Fiszel Co-authored-by: Claude Opus 4.8 (1M context) --- frontend/src/lib/components/home/ItemsList.svelte | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/frontend/src/lib/components/home/ItemsList.svelte b/frontend/src/lib/components/home/ItemsList.svelte index ca41e55349..256b2277f5 100644 --- a/frontend/src/lib/components/home/ItemsList.svelte +++ b/frontend/src/lib/components/home/ItemsList.svelte @@ -329,11 +329,17 @@ let allLabels = $derived( Array.from(new Set(combinedItems?.flatMap((x) => itemLabels(x)) ?? [])).sort() ) + let prevWorkspace: string | undefined = undefined + // Clear filters only when the workspace actually changes. The initial + // resolution must be left alone so URL-loaded filter values (set by + // ListFilters.loadFilterFromUrl on mount) survive the async store settling. $effect(() => { - if ($workspaceStore) { + const ws = $workspaceStore + if (ws && prevWorkspace !== undefined && ws !== prevWorkspace) { ownerFilter = undefined labelFilter = undefined } + prevWorkspace = ws }) let preFilteredItems = $derived( ownerFilter != undefined