修复搜索框在某些情况下输入内容后搜索时会自动清空的问题(#1472)

This commit is contained in:
lyswhut
2023-07-18 18:39:12 +08:00
parent 6c0e11eebc
commit e7f3f27104
3 changed files with 23 additions and 8 deletions
@@ -168,14 +168,20 @@ export default {
})
},
handleKeyDown() {
if (!this.resultList.length) return
this.selectIndex = this.selectIndex + 1 < this.resultList.length ? this.selectIndex + 1 : 0
this.handleScrollList()
if (this.resultList.length) {
this.selectIndex = this.selectIndex + 1 < this.resultList.length ? this.selectIndex + 1 : 0
this.handleScrollList()
} else if (this.selectIndex > -1) {
this.selectIndex = -1
}
},
handleKeyUp() {
if (!this.resultList.length) return
this.selectIndex = this.selectIndex - 1 < -1 ? this.resultList.length - 1 : this.selectIndex - 1
this.handleScrollList()
if (this.resultList.length) {
this.selectIndex = this.selectIndex - 1 < -1 ? this.resultList.length - 1 : this.selectIndex - 1
this.handleScrollList()
} else if (this.selectIndex > -1) {
this.selectIndex = -1
}
},
handleScrollList() {
if (this.selectIndex < 0) return