search fixes

This commit is contained in:
Bui 2022-02-25 18:29:56 +00:00
parent 6c8b635c2a
commit ca9c602b67

View File

@ -410,31 +410,30 @@ class SongSelect{
}else if (this.search){ }else if (this.search){
if(name === "back" || (event && event.code === "KeyF" && ctrl)) { if(name === "back" || (event && event.code === "KeyF" && ctrl)) {
this.removeSearch(true) this.removeSearch(true)
}else if(name === "down"){ }else if(name === "down" && this.search.results.length){
if(this.search.input == document.activeElement && this.search.results){ if(this.search.input == document.activeElement && this.search.results){
this.searchSetActive(0) this.searchSetActive(0)
}else if(this.search.active === this.search.results.length-1){ }else if(this.search.active === this.search.results.length-1){
this.searchSetActive(null) this.searchSetActive(null)
this.search.input.focus() this.search.input.focus()
}else if(this.search.active !== null){ }else if(Number.isInteger(this.search.active)){
this.searchSetActive(this.search.active+1) this.searchSetActive(this.search.active+1)
}else{ }else{
this.searchSetActive(0) this.searchSetActive(0)
} }
}else if(name === "up"){ }else if(name === "up" && this.search.results.length){
if(this.search.input == document.activeElement && this.search.results){ if(this.search.input == document.activeElement && this.search.results){
this.searchSetActive(this.search.results.length-1) this.searchSetActive(this.search.results.length-1)
}else if(this.search.active === 0){ }else if(this.search.active === 0){
this.searchSetActive(null) this.searchSetActive(null)
this.search.input.focus() this.search.input.focus()
//this.search.input.setSelectionRange(this.search.input.value.length, this.search.input.value.length) }else if(Number.isInteger(this.search.active)){
}else if(this.search.active !== null){
this.searchSetActive(this.search.active-1) this.searchSetActive(this.search.active-1)
}else{ }else{
this.searchSetActive(this.search.results.length-1) this.searchSetActive(this.search.results.length-1)
} }
}else if(name === "confirm"){ }else if(name === "confirm"){
if(this.search.active !== null){ if(Number.isInteger(this.search.active)){
this.searchProceed(parseInt(this.search.results[this.search.active].dataset.song_id)) this.searchProceed(parseInt(this.search.results[this.search.active].dataset.song_id))
} }
} }