From 65b98f3bd40875a29a539c6a6c1db52536b25d66 Mon Sep 17 00:00:00 2001 From: gx Date: Tue, 16 Mar 2021 09:56:56 +0800 Subject: [PATCH] fix: keep latest action to judge whether a node is to be expanded --- src/Tree.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Tree.js b/src/Tree.js index 59e2780..85f667c 100644 --- a/src/Tree.js +++ b/src/Tree.js @@ -810,6 +810,7 @@ onExpand(treeNode,keyType) { } const filterExpandedKeys = []; const removeRoot = this.latestState === false && props.canCloseFreely + const cachedLatestState = this.latestState // 这个值用来判断此次刷新是否是因为点击了展开/收回 this.latestState = null loopAllChildren(props.children, (item, index, pos, newKey) => { if (expandAll) { @@ -817,7 +818,7 @@ onExpand(treeNode,keyType) { } else if (props.autoExpandParent) { expandedPositionArr.forEach(p => { if ((p.split('-').length > pos.split('-').length && isInclude(pos.split('-'), p.split('-')) || pos === p) && filterExpandedKeys.indexOf(newKey) === -1) { - if (!props.canCloseFreely || (this.cacheExpandedKeys ? this.cacheExpandedKeys.has(newKey) : true)) { + if (!props.canCloseFreely || (cachedLatestState === null ? true : this.cacheExpandedKeys ? this.cacheExpandedKeys.has(newKey) : true)) { filterExpandedKeys.push(newKey); } }