diff --git a/components/user/UserSignIn.vue b/components/user/UserSignIn.vue index 75a23563..b729a3a4 100644 --- a/components/user/UserSignIn.vue +++ b/components/user/UserSignIn.vue @@ -62,8 +62,12 @@ const filteredServers = $computed(() => { return results }) +function toSelector(server: string) { + return server.replace(/[^\w-]/g, '-') +} function move(delta: number) { autocompleteIndex = ((autocompleteIndex + delta) + filteredServers.length) % filteredServers.length + document.querySelector(`#${toSelector(filteredServers[autocompleteIndex])}`)?.scrollIntoView(false) } function onEnter(e: KeyboardEvent) { @@ -74,6 +78,10 @@ function onEnter(e: KeyboardEvent) { } } +function select(index: number) { + server = filteredServers[index] +} + onMounted(async () => { input?.focus() knownServers = await $fetch('/api/list-servers') @@ -111,24 +119,27 @@ onMounted(async () => { @keydown.up="move(-1)" @keydown.enter="onEnter" @keydown.esc.prevent="autocompleteShow = false" - @blur="autocompleteShow = false" @focus="autocompleteShow = true" >
-
{{ name }} -
+