修正树节点选中,父节点自动展开

This commit is contained in:
kilo5hz 2021-11-18 17:20:27 +08:00
parent dced95c497
commit aed389c17b

View File

@ -115,10 +115,11 @@ const Script = ({ headerStyle, isPhone, theme }: any) => {
node: { node: {
title: s, title: s,
value: s, value: s,
key: `${p}-${s}`, key: p ? `${p}-${s}` : s,
parent: p, parent: p,
}, },
}; };
setExpandedKeys([p]);
onTreeSelect([`${p}-${s}`], obj); onTreeSelect([`${p}-${s}`], obj);
} }
}; };
@ -136,6 +137,10 @@ const Script = ({ headerStyle, isPhone, theme }: any) => {
getDetail(node); getDetail(node);
}; };
const onExpand = (expKeys: any) => {
setExpandedKeys(expKeys);
};
const onTreeSelect = useCallback( const onTreeSelect = useCallback(
(keys: Key[], e: any) => { (keys: Key[], e: any) => {
const content = editorRef.current const content = editorRef.current
@ -468,6 +473,8 @@ const Script = ({ headerStyle, isPhone, theme }: any) => {
showIcon={true} showIcon={true}
height={height} height={height}
selectedKeys={[select]} selectedKeys={[select]}
expandedKeys={expandedKeys}
onExpand={onExpand}
showLine={{ showLeafIcon: true }} showLine={{ showLeafIcon: true }}
onSelect={onTreeSelect} onSelect={onTreeSelect}
></Tree> ></Tree>