fix(timeline): mark the event form dirty on date/precision/picker changes
Some checks failed
CI / Unit & Component Tests (pull_request) Failing after 4m53s
CI / OCR Service Tests (pull_request) Successful in 24s
CI / Backend Unit Tests (pull_request) Successful in 5m46s
CI / fail2ban Regex (pull_request) Failing after 46s
CI / Semgrep Security Scan (pull_request) Successful in 25s
CI / Compose Bucket Idempotency (pull_request) Successful in 1m7s
SDD Gate / RTM Check (pull_request) Successful in 17s
SDD Gate / Contract Validate (pull_request) Successful in 24s
SDD Gate / Constitution Impact (pull_request) Successful in 19s
Some checks failed
CI / Unit & Component Tests (pull_request) Failing after 4m53s
CI / OCR Service Tests (pull_request) Successful in 24s
CI / Backend Unit Tests (pull_request) Successful in 5m46s
CI / fail2ban Regex (pull_request) Failing after 46s
CI / Semgrep Security Scan (pull_request) Successful in 25s
CI / Compose Bucket Idempotency (pull_request) Successful in 1m7s
SDD Gate / RTM Check (pull_request) Successful in 17s
SDD Gate / Contract Validate (pull_request) Successful in 24s
SDD Gate / Constitution Impact (pull_request) Successful in 19s
The beforeNavigate unsaved-changes guard only fired for title/type/description (their oninput/onchange hooks set `dirty`). Editing only the date, precision, end-date, or the linked persons/documents left `dirty` false, so a curator could navigate away and silently lose those edits — defeating the guard for the senior author audience. Add an $effect that watches those values and marks dirty on any change after the initial prop snapshot (first run only arms the watcher). Addresses PR #832 review (round-2 clean-agent concern). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user