forked from Mirrors/elk
fix: empty server list throws console error on move (#1048)
Co-authored-by: 三咲智子 Kevin Deng <sxzz@sxzz.moe>
This commit is contained in:
parent
6cb3183c2e
commit
23532062f5
1 changed files with 4 additions and 0 deletions
|
@ -94,6 +94,10 @@ function toSelector(server: string) {
|
|||
return server.replace(/[^\w-]/g, '-')
|
||||
}
|
||||
function move(delta: number) {
|
||||
if (filteredServers.length === 0) {
|
||||
autocompleteIndex = 0
|
||||
return
|
||||
}
|
||||
autocompleteIndex = ((autocompleteIndex + delta) + filteredServers.length) % filteredServers.length
|
||||
document.querySelector(`#${toSelector(filteredServers[autocompleteIndex])}`)?.scrollIntoView(false)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue