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
|
@ -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