diff --git a/publish/changeLog.md b/publish/changeLog.md index 884f862d..83785a69 100644 --- a/publish/changeLog.md +++ b/publish/changeLog.md @@ -11,6 +11,7 @@ - 修复搜索提示功能失效的问题(#1452, @Folltoshe) - 修复我的列表名右键菜单-排序歌曲按专辑名排序无效的问题(#1440) - 修复若路径存在 # 字符时,软件无法启动的问题 +- 修复搜索框在某些情况下输入内容后搜索时会自动清空的问题(#1472) ### 其他 diff --git a/src/renderer/components/material/SearchInput.vue b/src/renderer/components/material/SearchInput.vue index 76ce39d2..ba6ffc3e 100644 --- a/src/renderer/components/material/SearchInput.vue +++ b/src/renderer/components/material/SearchInput.vue @@ -162,10 +162,18 @@ export default { }) }, handleKeyDown() { - this.selectIndex = this.selectIndex + 1 < this.list.length ? this.selectIndex + 1 : 0 + if (this.list.length) { + this.selectIndex = this.selectIndex + 1 < this.list.length ? this.selectIndex + 1 : 0 + } else if (this.selectIndex > -1) { + this.selectIndex = -1 + } }, handleKeyUp() { - this.selectIndex = this.selectIndex - 1 < -1 ? this.list.length - 1 : this.selectIndex - 1 + if (this.list.length) { + this.selectIndex = this.selectIndex - 1 < -1 ? this.list.length - 1 : this.selectIndex - 1 + } else if (this.selectIndex > -1) { + this.selectIndex = -1 + } }, handleContextMenu() { let str = clipboardReadText() diff --git a/src/renderer/views/List/MusicList/components/SearchList.vue b/src/renderer/views/List/MusicList/components/SearchList.vue index c7489d90..1535fd6e 100644 --- a/src/renderer/views/List/MusicList/components/SearchList.vue +++ b/src/renderer/views/List/MusicList/components/SearchList.vue @@ -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