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); }