diff --git a/frontend/src/routes/+layout.svelte b/frontend/src/routes/+layout.svelte index f3ab93b1..9a121f7a 100644 --- a/frontend/src/routes/+layout.svelte +++ b/frontend/src/routes/+layout.svelte @@ -10,6 +10,7 @@ import AppNav from './AppNav.svelte'; import UserMenu from './UserMenu.svelte'; import ConfirmDialog from '$lib/components/ConfirmDialog.svelte'; import { provideConfirmService } from '$lib/services/confirm.svelte.js'; +import { bulkSelectionStore } from '$lib/stores/bulkSelection.svelte'; let { children, data } = $props(); @@ -17,6 +18,22 @@ let { children, data } = $props(); // ConfirmDialog below reads it via getConfirmService() and renders the . provideConfirmService(); +// Auto-clear the bulk-selection store when the user leaves the routes that +// surface the BulkSelectionBar. Without this the selection silently follows +// the user to /persons / /admin etc. and reappears as a stale 3-doc count +// when they wander back to /documents — Felix C4 on PR #331. +$effect(() => { + const path = page.url.pathname; + const inBulkContext = + path === '/documents' || + path.startsWith('/documents/') || + path === '/enrich' || + path.startsWith('/enrich/'); + if (!inBulkContext && bulkSelectionStore.size > 0) { + bulkSelectionStore.clear(); + } +}); + const isAdmin = $derived( data?.user?.groups?.some((g: { permissions: string[] }) => g.permissions.includes('ADMIN')) );