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

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