fix(timeline): clear required-field errors when the field is corrected
titleError/dateError short-circuited on the server fail payload (`form?.titleError ?? …`, `form?.dateError ?? ''`), so after a fail(400) the red border and message stuck until the next submit even once the user typed a valid value. Derive both from the current field value instead: the server error still seeds the message, but a non-empty title/date clears it immediately. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -91,12 +91,13 @@ let submitting = $state(false);
|
||||
let dirty = $state(false);
|
||||
|
||||
const titleEmpty = $derived(title.trim().length === 0);
|
||||
// Client-side title error fires instantly on a save attempt; the server's
|
||||
// titleError is the simultaneous-multi-field source on a real round-trip.
|
||||
// Required-field errors derive from the CURRENT field value, not the stale server
|
||||
// payload: a server titleError/dateError seeds the message, but typing a valid
|
||||
// value clears it immediately instead of sticking until the next submit.
|
||||
const titleError = $derived(
|
||||
form?.titleError ?? (titleTouched && titleEmpty ? m.event_editor_title_required() : '')
|
||||
titleEmpty && (titleTouched || !!form?.titleError) ? m.event_editor_title_required() : ''
|
||||
);
|
||||
const dateError = $derived(form?.dateError ?? '');
|
||||
const dateError = $derived(dateIso ? '' : (form?.dateError ?? ''));
|
||||
|
||||
beforeNavigate(({ cancel }) => {
|
||||
if (dirty && !submitting) {
|
||||
|
||||
Reference in New Issue
Block a user