Timeline: curator event create/edit forms (#781) #832
@@ -105,6 +105,22 @@ function markDirty() {
|
|||||||
dirty = true;
|
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
|
// Guards a submit with a blank title client-side. The server re-validates and
|
||||||
// owns the authoritative fail(400) with per-field flags.
|
// owns the authoritative fail(400) with per-field flags.
|
||||||
function handleSubmit(e: SubmitEvent) {
|
function handleSubmit(e: SubmitEvent) {
|
||||||
|
|||||||
Reference in New Issue
Block a user