Fix:修复只读模式下连续输入不同文字搜索,上一个搜索到的高亮节点没有清除的问题

This commit is contained in:
街角小林 2024-12-23 09:33:00 +08:00
parent c342fbbe75
commit f490ac6f8d

View File

@ -107,6 +107,7 @@ class Search {
// 搜索匹配的节点
doSearch() {
this.clearHighlightOnReadonly()
this.updateMatchNodeList([])
this.currentIndex = -1
const { isOnlySearchCurrentRenderNodes } = this.mindMap.opt
@ -174,14 +175,8 @@ class Search {
}
}
const { readonly } = this.mindMap.opt
// 只读模式下需要激活之前节点的高亮
if (readonly) {
this.matchNodeList.forEach(node => {
if (this.isNodeInstance(node)) {
node.closeHighlight()
}
})
}
// 只读模式下需要清除之前节点的高亮
this.clearHighlightOnReadonly()
const currentNode = this.matchNodeList[this.currentIndex]
this.notResetSearchText = true
const uid = this.isNodeInstance(currentNode)
@ -205,6 +200,18 @@ class Search {
})
}
// 只读模式下清除现有匹配节点的高亮
clearHighlightOnReadonly() {
const { readonly } = this.mindMap.opt
if (readonly) {
this.matchNodeList.forEach(node => {
if (this.isNodeInstance(node)) {
node.closeHighlight()
}
})
}
}
// 定位到指定搜索结果索引的节点
jump(index, callback = () => {}) {
this.searchNext(callback, index)