diff --git a/src/LiteFlowEditor/panels/settingBar/outline/index.tsx b/src/LiteFlowEditor/panels/settingBar/outline/index.tsx index b387825467642025fe0dc334bd795a3cd5144d33..fdb523d847154c62978ba511836907b3e9ba92b1 100644 --- a/src/LiteFlowEditor/panels/settingBar/outline/index.tsx +++ b/src/LiteFlowEditor/panels/settingBar/outline/index.tsx @@ -1,12 +1,12 @@ -import React, { useEffect, useState, MouseEventHandler } from 'react'; -import classNames from 'classnames'; +import { DownOutlined } from '@ant-design/icons'; import { Graph, StringExt } from '@antv/x6'; import { Tree } from 'antd'; -import { DownOutlined } from '@ant-design/icons'; import type { DataNode } from 'antd/es/tree'; +import classNames from 'classnames'; +import React, { MouseEventHandler, useEffect, useState } from 'react'; +import { getIconByType } from '../../../cells'; import { useModel } from '../../../hooks/useModel'; import ELNode from '../../../model/node'; -import { getIconByType } from '../../../cells'; import styles from './index.module.less'; interface IProps { @@ -39,7 +39,6 @@ const Outline: React.FC = (props) => { function transformer(currentModel: ELNode, keys: string[]): DataNode { const handleClick = () => { - // 始终递归展开节点,再选中 function findParentCollapsed(currentModel: ELNode) { if (currentModel.parent) { @@ -53,7 +52,7 @@ const Outline: React.FC = (props) => { // 触发model:change事件来更新视图 flowGraph.trigger('model:change'); // 找到了选中的节点 - let node + let node; const nodes = currentModel?.getNodes(); if (nodes && nodes.length > 0) { node = nodes[0]; @@ -67,7 +66,10 @@ const Outline: React.FC = (props) => { flowGraph.trigger('model:select', currentModel); flowGraph.select(nodes); }; - const key = `${currentModel.type}-${StringExt.uuid()}`; + const key = currentModel.id + ? `${currentModel.type}-${currentModel.id}` + : `${currentModel.type}-${StringExt.uuid()}`; + keys.push(key); const node: DataNode = { title: , @@ -109,7 +111,9 @@ const Outline: React.FC = (props) => { flowGraph.off('model:change', handleModelChange); }; }, [flowGraph, setTreeData]); - + const onExpand = (keys: React.Key[]) => { + setExpandedKeys(keys as string[]); + }; return (
= (props) => { showLine={{ showLeafIcon: false }} switcherIcon={} expandedKeys={expandedKeys} + onExpand={onExpand} selectedKeys={[]} treeData={treeData} />