fix: keep latest action to judge whether a node is to be expanded

This commit is contained in:
gx 2021-03-16 09:56:56 +08:00
parent dcd1ae1bcd
commit 65b98f3bd4
1 changed files with 2 additions and 1 deletions

View File

@ -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);
}
}