From fb1f407016d71ab72d481641d1ffc4ec0e32eb6a Mon Sep 17 00:00:00 2001 From: baptiste0928 <22115890+baptiste0928@users.noreply.github.com> Date: Wed, 18 Jan 2023 14:54:17 +0100 Subject: [PATCH] feat(search): select first result on enter press (#1289) --- components/search/SearchWidget.vue | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/components/search/SearchWidget.vue b/components/search/SearchWidget.vue index 12d27f19..aa3cdf84 100644 --- a/components/search/SearchWidget.vue +++ b/components/search/SearchWidget.vue @@ -37,17 +37,19 @@ const shift = (delta: number) => index.value = (index.value + delta % results.va const activate = () => { const currentIndex = index.value - index.value = -1 if (query.value.length === 0) return - (document.activeElement as HTMLElement).blur() - - // Disable until search page is implemented - if (currentIndex === -1) + // Disable redirection until search page is implemented + if (currentIndex === -1) { + index.value = 0 // router.push(`/search?q=${query.value}`) return + } + + (document.activeElement as HTMLElement).blur() + index.value = -1 router.push(results.value[currentIndex].to) }