diff --git a/apps/ai-game-creator-shell/src/view/ui-editor/components/Inspector/Components/ComponentPanel.tsx b/apps/ai-game-creator-shell/src/view/ui-editor/components/Inspector/Components/ComponentPanel.tsx index 89d20155c..30089990f 100644 --- a/apps/ai-game-creator-shell/src/view/ui-editor/components/Inspector/Components/ComponentPanel.tsx +++ b/apps/ai-game-creator-shell/src/view/ui-editor/components/Inspector/Components/ComponentPanel.tsx @@ -1,5 +1,5 @@ import { ChevronDown, ChevronRight, Plus, Trash2 } from 'lucide-react'; -import { useState } from 'react'; +import { useEffect, useState } from 'react'; import type { Component } from '../../../../../features/ui-editor/types/Component'; import type { UiEditorOperationResult } from '../../../../../features/ui-editor/useUiEditorState'; @@ -18,6 +18,10 @@ export function ComponentPanel(props: ComponentPanelProps) { const [expanded, setExpanded] = useState(Boolean(component)); const [error, setError] = useState(null); + useEffect(() => { + setExpanded(Boolean(component)); + }, [component]); + function setComponent(next: Component | null) { if (readOnly) return undefined; const result = onSetComponent(next);