Fix create-mode crash in detail panels (null entity access)
The desktop detail panels are pre-mounted (always in DOM, hidden with w-0). useState(isCreating) only captures the initial value on mount (false), so when isCreating later becomes true via props, isEditing stays false. The view-mode branch then runs with a null entity, crashing on property access. Fix: use (isEditing || isCreating) for all conditionals that gate between edit/create form and view mode, ensuring the form always renders when isCreating is true regardless of isEditing state. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
f07ce02576
commit
a128005ae5
@ -480,7 +480,7 @@ export default function EventDetailPanel({
|
||||
>
|
||||
<X className="h-3.5 w-3.5" />
|
||||
</Button>
|
||||
) : isEditing ? (
|
||||
) : (isEditing || isCreating) ? (
|
||||
<>
|
||||
<Button
|
||||
variant="ghost"
|
||||
@ -586,7 +586,7 @@ export default function EventDetailPanel({
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
) : isEditing ? (
|
||||
) : (isEditing || isCreating) ? (
|
||||
/* Edit / Create mode */
|
||||
<div className="space-y-4">
|
||||
{/* Title (only shown in body for create mode; edit mode has it in header) */}
|
||||
|
||||
@ -224,7 +224,7 @@ export default function ReminderDetailPanel({
|
||||
)}
|
||||
|
||||
<div className="flex items-center gap-1 shrink-0">
|
||||
{isEditing ? (
|
||||
{(isEditing || isCreating) ? (
|
||||
<>
|
||||
<Button
|
||||
variant="ghost"
|
||||
@ -308,7 +308,7 @@ export default function ReminderDetailPanel({
|
||||
|
||||
{/* Body */}
|
||||
<div className="flex-1 overflow-y-auto px-5 py-4 space-y-3">
|
||||
{isEditing ? (
|
||||
{(isEditing || isCreating) ? (
|
||||
/* Edit / Create mode */
|
||||
<div className="space-y-4">
|
||||
{isCreating && (
|
||||
|
||||
@ -254,7 +254,7 @@ export default function TodoDetailPanel({
|
||||
)}
|
||||
|
||||
<div className="flex items-center gap-1 shrink-0">
|
||||
{isEditing ? (
|
||||
{(isEditing || isCreating) ? (
|
||||
<>
|
||||
<Button
|
||||
variant="ghost"
|
||||
@ -326,7 +326,7 @@ export default function TodoDetailPanel({
|
||||
|
||||
{/* Body */}
|
||||
<div className="flex-1 overflow-y-auto px-5 py-4 space-y-3">
|
||||
{isEditing ? (
|
||||
{(isEditing || isCreating) ? (
|
||||
/* Edit / Create mode */
|
||||
<div className="space-y-4">
|
||||
{isCreating && (
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user