Fix:修复某些情况下搜索时数据改变,搜索结果没有更新的问题

This commit is contained in:
街角小林 2024-02-27 10:15:09 +08:00
parent c0fea992a9
commit 8b90557f70

View File

@ -112,22 +112,25 @@ class Search {
}
const currentNode = this.matchNodeList[this.currentIndex]
this.notResetSearchText = true
this.mindMap.execCommand(
'GO_TARGET_NODE',
currentNode instanceof Node ? currentNode : currentNode.data.uid,
node => {
if (!(currentNode instanceof Node)) {
this.matchNodeList[this.currentIndex] = node
} else {
this.notResetSearchText = false
}
callback()
// 只读模式下节点无法激活,所以通过高亮的方式
if (this.mindMap.opt.readonly) {
node.highlight()
}
const uid =
currentNode instanceof Node
? currentNode.getData('uid')
: currentNode.data.uid
const targetNode = this.mindMap.renderer.findNodeByUid(uid)
this.mindMap.execCommand('GO_TARGET_NODE', uid, node => {
if (!(currentNode instanceof Node)) {
this.matchNodeList[this.currentIndex] = node
}
)
callback()
// 只读模式下节点无法激活,所以通过高亮的方式
if (this.mindMap.opt.readonly) {
node.highlight()
}
// 如果当前节点实例已经存在则不会触发data_change事件那么需要手动把标志复位
if (targetNode) {
this.notResetSearchText = false
}
})
}
// 替换当前节点