From 46eb908ff4d2693d4cc702509e1529836b87a84f Mon Sep 17 00:00:00 2001 From: Marcel Date: Mon, 30 Mar 2026 21:22:43 +0200 Subject: [PATCH] fix(DateInput): fire onchange when field is cleared Clearing the input set value='' but did not call onchange, so the korrespondenz filter strip never re-fetched. Added onchange?.() in the empty-display branch and added a test that confirms the callback fires. Co-Authored-By: Claude Sonnet 4.6 --- frontend/src/lib/components/DateInput.svelte | 1 + frontend/src/lib/components/DateInput.svelte.spec.ts | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/frontend/src/lib/components/DateInput.svelte b/frontend/src/lib/components/DateInput.svelte index 3314105a..8a7dbbd1 100644 --- a/frontend/src/lib/components/DateInput.svelte +++ b/frontend/src/lib/components/DateInput.svelte @@ -31,6 +31,7 @@ function handleInput(e: Event) { if (result.display === '') { value = ''; errorMessage = null; + onchange?.(); return; } diff --git a/frontend/src/lib/components/DateInput.svelte.spec.ts b/frontend/src/lib/components/DateInput.svelte.spec.ts index 6ba990d1..d8704aef 100644 --- a/frontend/src/lib/components/DateInput.svelte.spec.ts +++ b/frontend/src/lib/components/DateInput.svelte.spec.ts @@ -173,6 +173,14 @@ describe('DateInput – clearing the date', () => { expect(value).toBe(''); expect(errorMessage).toBeNull(); }); + + it('fires onchange when the field is cleared', async () => { + let called = 0; + render(DateInput, { value: '2024-12-20', onchange: () => called++ }); + const input = page.getByRole('textbox'); + await input.fill(''); + expect(called).toBeGreaterThan(0); + }); }); // ─── Hidden input ─────────────────────────────────────────────────────────────