mirror of
https://github.com/elk-zone/elk.git
synced 2024-09-06 12:19:08 +01:00
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, '-')
|
return server.replace(/[^\w-]/g, '-')
|
||||||
}
|
}
|
||||||
function move(delta: number) {
|
function move(delta: number) {
|
||||||
|
if (filteredServers.length === 0) {
|
||||||
|
autocompleteIndex = 0
|
||||||
|
return
|
||||||
|
}
|
||||||
autocompleteIndex = ((autocompleteIndex + delta) + filteredServers.length) % filteredServers.length
|
autocompleteIndex = ((autocompleteIndex + delta) + filteredServers.length) % filteredServers.length
|
||||||
document.querySelector(`#${toSelector(filteredServers[autocompleteIndex])}`)?.scrollIntoView(false)
|
document.querySelector(`#${toSelector(filteredServers[autocompleteIndex])}`)?.scrollIntoView(false)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue