From 63bc24d2f1d6f5f1031eb8180532b546c8502ea4 Mon Sep 17 00:00:00 2001 From: Marcel Date: Tue, 9 Jun 2026 17:51:26 +0200 Subject: [PATCH] fix(journey-editor): send {"note":null} on clear instead of omitting key MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit null ?? undefined evaluated to undefined, causing JSON.stringify to omit the key entirely — the backend treated an absent note field as a no-op, so clearing a note never persisted. Co-Authored-By: Claude Sonnet 4.6 --- frontend/src/lib/geschichte/JourneyEditor.svelte | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/frontend/src/lib/geschichte/JourneyEditor.svelte b/frontend/src/lib/geschichte/JourneyEditor.svelte index a0a4da72..89131f2e 100644 --- a/frontend/src/lib/geschichte/JourneyEditor.svelte +++ b/frontend/src/lib/geschichte/JourneyEditor.svelte @@ -43,6 +43,7 @@ let items: JourneyItemView[] = $state( let titleTouched = $state(false); let mutationError = $state(''); let liveAnnounce = $state(''); +let announceTimer: ReturnType | null = null; const titleEmpty = $derived(title.trim().length === 0); const showTitleError = $derived(titleEmpty && titleTouched); @@ -138,7 +139,7 @@ async function handleNotePatch(itemId: string, note: string | null) { const res = await csrfFetch(`/api/geschichten/${geschichte.id}/items/${itemId}`, { method: 'PATCH', headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ note: note ?? undefined }) + body: JSON.stringify({ note: note }) }); if (!res.ok) throw new Error('note patch failed'); const updated: JourneyItemView = await res.json(); @@ -156,8 +157,10 @@ async function handleMoveUp(index: number) { }); await handleReorder(ids); // Clear so the live region does not re-announce on unrelated DOM mutations - setTimeout(() => { + if (announceTimer) clearTimeout(announceTimer); + announceTimer = setTimeout(() => { liveAnnounce = ''; + announceTimer = null; }, 500); } @@ -172,8 +175,10 @@ async function handleMoveDown(index: number) { }); await handleReorder(ids); // Clear so the live region does not re-announce on unrelated DOM mutations - setTimeout(() => { + if (announceTimer) clearTimeout(announceTimer); + announceTimer = setTimeout(() => { liveAnnounce = ''; + announceTimer = null; }, 500); }