From f07ce02576d9b14937d3d3eb188f74fb866dae22 Mon Sep 17 00:00:00 2001 From: Kyle Pope Date: Fri, 27 Feb 2026 08:35:31 +0800 Subject: [PATCH] Fix crash when creating new todo/reminder/event (null.priority) All three DetailPanel components initialized isEditing=false even when isCreating=true. The useEffect that flips it to true runs AFTER the first render, so the view-mode branch executes with todo=null, crashing on null.priority. Initialize isEditing from isCreating. Co-Authored-By: Claude Opus 4.6 --- frontend/src/components/calendar/EventDetailPanel.tsx | 2 +- frontend/src/components/reminders/ReminderDetailPanel.tsx | 2 +- frontend/src/components/todos/TodoDetailPanel.tsx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/calendar/EventDetailPanel.tsx b/frontend/src/components/calendar/EventDetailPanel.tsx index 863cffb..de40dc1 100644 --- a/frontend/src/components/calendar/EventDetailPanel.tsx +++ b/frontend/src/components/calendar/EventDetailPanel.tsx @@ -232,7 +232,7 @@ export default function EventDetailPanel({ staleTime: 5 * 60 * 1000, }); - const [isEditing, setIsEditing] = useState(false); + const [isEditing, setIsEditing] = useState(isCreating); const [editState, setEditState] = useState(() => isCreating ? buildCreateState(createDefaults ?? null, defaultCalendar?.id?.toString() || '') diff --git a/frontend/src/components/reminders/ReminderDetailPanel.tsx b/frontend/src/components/reminders/ReminderDetailPanel.tsx index 0a101e8..79be3d5 100644 --- a/frontend/src/components/reminders/ReminderDetailPanel.tsx +++ b/frontend/src/components/reminders/ReminderDetailPanel.tsx @@ -70,7 +70,7 @@ export default function ReminderDetailPanel({ }: ReminderDetailPanelProps) { const queryClient = useQueryClient(); - const [isEditing, setIsEditing] = useState(false); + const [isEditing, setIsEditing] = useState(isCreating); const [editState, setEditState] = useState(() => isCreating ? buildCreateState() : reminder ? buildEditState(reminder) : buildCreateState() ); diff --git a/frontend/src/components/todos/TodoDetailPanel.tsx b/frontend/src/components/todos/TodoDetailPanel.tsx index fd9a03a..ee34ef6 100644 --- a/frontend/src/components/todos/TodoDetailPanel.tsx +++ b/frontend/src/components/todos/TodoDetailPanel.tsx @@ -95,7 +95,7 @@ export default function TodoDetailPanel({ }: TodoDetailPanelProps) { const queryClient = useQueryClient(); - const [isEditing, setIsEditing] = useState(false); + const [isEditing, setIsEditing] = useState(isCreating); const [editState, setEditState] = useState(() => isCreating ? buildCreateState(createDefaults) : todo ? buildEditState(todo) : buildCreateState() );