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 ─────────────────────────────────────────────────────────────