diff --git a/frontend/src/components/tree-editor/NodeEditorPanel.tsx b/frontend/src/components/tree-editor/NodeEditorPanel.tsx index 02054e96..bac752b0 100644 --- a/frontend/src/components/tree-editor/NodeEditorPanel.tsx +++ b/frontend/src/components/tree-editor/NodeEditorPanel.tsx @@ -20,7 +20,7 @@ const TYPE_CONFIG: Record, { icon: typeof HelpCircle } function cloneWithoutChildren(node: TreeStructure): TreeStructure { - const { children, ...rest } = node + const { children: _children, ...rest } = node return structuredClone(rest) as TreeStructure } @@ -47,17 +47,6 @@ export function NodeEditorPanel({ nodeId, onClose, onSelectType }: NodeEditorPan } }, [nodeId]) // eslint-disable-line react-hooks/exhaustive-deps - // Escape to close - useEffect(() => { - const handleKeyDown = (e: KeyboardEvent) => { - if (e.key === 'Escape') { - handleClose() - } - } - document.addEventListener('keydown', handleKeyDown) - return () => document.removeEventListener('keydown', handleKeyDown) - }, [isDirty]) // eslint-disable-line react-hooks/exhaustive-deps - const handleDraftUpdate = useCallback((updates: Partial) => { setDraft(prev => prev ? { ...prev, ...updates } : prev) setIsDirty(true) @@ -65,7 +54,7 @@ export function NodeEditorPanel({ nodeId, onClose, onSelectType }: NodeEditorPan const handleSave = useCallback(() => { if (!draft || !node) return - const { children, ...draftWithoutChildren } = draft + const { children: _children, ...draftWithoutChildren } = draft updateNode(nodeId, draftWithoutChildren) // Auto-create answer stubs for new decision options without next_node_id @@ -100,6 +89,17 @@ export function NodeEditorPanel({ nodeId, onClose, onSelectType }: NodeEditorPan onClose() }, [isDirty, onClose]) + // Escape to close + useEffect(() => { + const handleKeyDown = (e: KeyboardEvent) => { + if (e.key === 'Escape') { + handleClose() + } + } + document.addEventListener('keydown', handleKeyDown) + return () => document.removeEventListener('keydown', handleKeyDown) + }, [handleClose]) + const handleDelete = useCallback(() => { if (!treeStructure) return clearInboundReferences(nodeId, treeStructure, updateNode) diff --git a/frontend/src/components/tree-editor/useTreeLayout.ts b/frontend/src/components/tree-editor/useTreeLayout.ts index 3c8aef2c..d0c146be 100644 --- a/frontend/src/components/tree-editor/useTreeLayout.ts +++ b/frontend/src/components/tree-editor/useTreeLayout.ts @@ -60,7 +60,7 @@ export function useTreeLayout(): UseTreeLayoutResult { if (!treeStructure) return { rawNodes: nodes, rawEdges: edges } - function walk(node: TreeStructure, _parentId: string | null) { + function walk(node: TreeStructure, _parentId?: string | null) { const isCollapsed = collapsedNodeIds.has(node.id) const hasChildren = (node.children?.length ?? 0) > 0 const hasErrors = validationErrors.some(e => e.nodeId === node.id && e.severity === 'error')