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 <noreply@anthropic.com>
This commit is contained in:
parent
0fc3f1a14b
commit
f07ce02576
@ -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<EditState>(() =>
|
||||
isCreating
|
||||
? buildCreateState(createDefaults ?? null, defaultCalendar?.id?.toString() || '')
|
||||
|
||||
@ -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<EditState>(() =>
|
||||
isCreating ? buildCreateState() : reminder ? buildEditState(reminder) : buildCreateState()
|
||||
);
|
||||
|
||||
@ -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<EditState>(() =>
|
||||
isCreating ? buildCreateState(createDefaults) : todo ? buildEditState(todo) : buildCreateState()
|
||||
);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user