fix: taskpanel savetask fix #256

Merged
harivansh-afk merged 1 commit from savetask-bug into main 2026-04-20 16:24:50 +00:00
harivansh-afk commented 2026-04-20 05:52:51 +00:00

Root cause:

In task-panel.tsx's saveTask, the due field is always
re-sent on every save — including the implicit save that fires on
popover close (the cleanup effect at useEffect(... if (!isOpen)
return; return () => void saveTask(id) ...)).

The due value in the form starts as t.due.slice(0, 16) — a string
like "2026-04-20T00:00" with no timezone suffix. On save it
round-trips through:

due: f.due ? new Date(f.due).toISOString() : null

Fix:

(src/components/task-panel.tsx)

• Snapshot the initial due string in initialDueRef when the form
loads (both edit and create modes).
• In saveTask, only include due in the update payload if the form
value actually differs from that snapshot.

Explanation:

This way, opening and closing the popover without touching the date
field is a no-op for due, so the event stays put. Real user edits to
due still go through normally.

Root cause: In task-panel.tsx's saveTask, the due field is always re-sent on every save — including the implicit save that fires on popover close (the cleanup effect at useEffect(... if (!isOpen) return; return () => void saveTask(id) ...)). The due value in the form starts as t.due.slice(0, 16) — a string like "2026-04-20T00:00" with no timezone suffix. On save it round-trips through: due: f.due ? new Date(f.due).toISOString() : null Fix: (src/components/task-panel.tsx) • Snapshot the initial due string in initialDueRef when the form loads (both edit and create modes). • In saveTask, only include due in the update payload if the form value actually differs from that snapshot. Explanation: This way, opening and closing the popover without touching the date field is a no-op for due, so the event stays put. Real user edits to due still go through normally.
Sign in to join this conversation.
No description provided.