同步检查器组件面板展开状态
切换节点或组件时重置展开状态,避免复用旧节点的折叠状态。
This commit is contained in:
+5
-1
@@ -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<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
setExpanded(Boolean(component));
|
||||
}, [component]);
|
||||
|
||||
function setComponent(next: Component | null) {
|
||||
if (readOnly) return undefined;
|
||||
const result = onSetComponent(next);
|
||||
|
||||
Reference in New Issue
Block a user