fix(journey-editor): send {"note":null} on clear instead of omitting key
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 <noreply@anthropic.com>
This commit is contained in:
@@ -43,6 +43,7 @@ let items: JourneyItemView[] = $state(
|
||||
let titleTouched = $state(false);
|
||||
let mutationError = $state('');
|
||||
let liveAnnounce = $state('');
|
||||
let announceTimer: ReturnType<typeof setTimeout> | 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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user