search suggestion out of index (#2353)

This commit is contained in:
bob1520 2022-07-01 08:29:10 +00:00 committed by GitHub
parent 65d36852ff
commit 3ccdf56699
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -199,13 +199,13 @@ export default Vue.extend({
}, },
handleKeyDown: function (keyCode) { handleKeyDown: function (keyCode) {
if (this.dataList.length === 0) { return } if (this.visibleDataList.length === 0) { return }
// Update selectedOption based on arrow key pressed // Update selectedOption based on arrow key pressed
if (keyCode === 40) { if (keyCode === 40) {
this.searchState.selectedOption = (this.searchState.selectedOption + 1) % this.dataList.length this.searchState.selectedOption = (this.searchState.selectedOption + 1) % this.visibleDataList.length
} else if (keyCode === 38) { } else if (keyCode === 38) {
if (this.searchState.selectedOption === -1) { if (this.searchState.selectedOption < 1) {
this.searchState.selectedOption = this.dataList.length - 1 this.searchState.selectedOption = this.visibleDataList.length - 1
} else { } else {
this.searchState.selectedOption-- this.searchState.selectedOption--
} }