diff --git a/frontend/src/lib/timeline/EventForm.svelte b/frontend/src/lib/timeline/EventForm.svelte index 46e51e98..38d752ea 100644 --- a/frontend/src/lib/timeline/EventForm.svelte +++ b/frontend/src/lib/timeline/EventForm.svelte @@ -105,6 +105,22 @@ function markDirty() { dirty = true; } +// title/type/description set `dirty` through their own oninput/onchange hooks, +// but the date/precision/end-date (inside DatePrecisionField) and the two pickers +// have no such hook — so changing only a date or a linked person would otherwise +// slip past the beforeNavigate guard. Watch those values and mark dirty on any +// change after the initial prop snapshot (the first run only arms the watcher). +let dirtyArmed = $state(false); +$effect(() => { + void dateIso; + void precision; + void endDateIso; + void selectedPersons.length; + void selectedDocuments.length; + if (dirtyArmed) dirty = true; + else dirtyArmed = true; +}); + // Guards a submit with a blank title client-side. The server re-validates and // owns the authoritative fail(400) with per-field flags. function handleSubmit(e: SubmitEvent) {