From 0cf4916c8be85047cf0f55090e5e32d5184fdfd1 Mon Sep 17 00:00:00 2001 From: Marcel Date: Sun, 7 Jun 2026 18:55:42 +0200 Subject: [PATCH] refactor(search): remove smart mode from SearchFilterBar Removes SmartModeToggle component import and all smart-mode conditional logic from SearchFilterBar, including mode-specific input handling, max-length constraints, and CSS class toggling. Removes associated smart-mode tests that verified chip lifecycle callbacks (onModeToggle, onSmartSearch). Co-Authored-By: Claude Sonnet 4.6 --- frontend/src/routes/SearchFilterBar.svelte | 27 ++------------ .../src/routes/SearchFilterBar.svelte.spec.ts | 36 ------------------- 2 files changed, 2 insertions(+), 61 deletions(-) diff --git a/frontend/src/routes/SearchFilterBar.svelte b/frontend/src/routes/SearchFilterBar.svelte index 779ab8f3..4817d0c6 100644 --- a/frontend/src/routes/SearchFilterBar.svelte +++ b/frontend/src/routes/SearchFilterBar.svelte @@ -3,7 +3,6 @@ import PersonTypeahead from '$lib/person/PersonTypeahead.svelte'; import TagInput from '$lib/tag/TagInput.svelte'; import DateInput from '$lib/shared/primitives/DateInput.svelte'; import SortDropdown from '$lib/shared/primitives/SortDropdown.svelte'; -import SmartModeToggle from './search/SmartModeToggle.svelte'; import { slide } from 'svelte/transition'; import { m } from '$lib/paraglide/messages.js'; @@ -21,15 +20,12 @@ let { sort = $bindable('DATE'), dir = $bindable('desc'), showAdvanced = $bindable(false), - smartMode = $bindable(false), initialSenderName = '', initialReceiverName = '', navKey = 0, isLoading = false, onSearch, onSearchImmediate, - onSmartSearch, - onModeToggle, onfocus, onblur }: { @@ -46,28 +42,16 @@ let { sort?: string; dir?: string; showAdvanced?: boolean; - smartMode?: boolean; initialSenderName?: string; initialReceiverName?: string; navKey?: number; isLoading?: boolean; onSearch: () => void; onSearchImmediate?: () => void; - onSmartSearch?: () => void; - onModeToggle?: () => void; onfocus?: () => void; onblur?: () => void; } = $props(); -// In smart mode the keyword search must not fire on every keystroke — the NL -// query is submitted only on Enter (or an explicit button click). -function onSearchKeydown(event: KeyboardEvent) { - if (smartMode && event.key === 'Enter') { - event.preventDefault(); - onSmartSearch?.(); - } -} - // Plain (non-reactive) flag — not $state, so no reactive assignment inside $effect let sortDirMounted = false; @@ -92,19 +76,13 @@ $effect(() => { -
{#if isLoading} { /> {/if}
- diff --git a/frontend/src/routes/SearchFilterBar.svelte.spec.ts b/frontend/src/routes/SearchFilterBar.svelte.spec.ts index 1de166f2..446cd046 100644 --- a/frontend/src/routes/SearchFilterBar.svelte.spec.ts +++ b/frontend/src/routes/SearchFilterBar.svelte.spec.ts @@ -195,39 +195,3 @@ describe('SearchFilterBar – tagQ live filter', () => { vi.unstubAllGlobals(); }); }); - -describe('SearchFilterBar – smart-mode chip lifecycle hooks', () => { - // The interpretation chips live in the result area (parent page). SearchFilterBar - // drives chip-clearing through callbacks: onModeToggle (mode switch) and - // onSmartSearch (new query). These tests pin that contract. - it('invokes onModeToggle when toggling back to keyword mode (parent clears chips)', async () => { - const onModeToggle = vi.fn(); - render(SearchFilterBar, { - ...defaultProps, - sort: 'DATE', - dir: 'desc', - smartMode: true, - onModeToggle - }); - await page.getByRole('button', { name: /Smart/ }).click(); - expect(onModeToggle).toHaveBeenCalledOnce(); - }); - - it('invokes onSmartSearch when a new query is submitted in smart mode (parent resets chips)', async () => { - const onSmartSearch = vi.fn(); - render(SearchFilterBar, { - ...defaultProps, - sort: 'DATE', - dir: 'desc', - smartMode: true, - onSmartSearch - }); - const input = page.getByPlaceholder('Titel, Personen, Tags durchsuchen…'); - await input.fill('Walter im Krieg'); - await input.click(); - (document.activeElement as HTMLElement).dispatchEvent( - new KeyboardEvent('keydown', { key: 'Enter', bubbles: true }) - ); - await vi.waitFor(() => expect(onSmartSearch).toHaveBeenCalled()); - }); -});