From 4ca2053bb2bda8d5f3a8d807923c402dee0ce630 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E6=99=BA=E5=AD=90?= Date: Sun, 8 Jan 2023 15:57:21 +0800 Subject: [PATCH] fix(search): error when not selected --- components/search/SearchWidget.vue | 8 +++++--- composables/masto/search.ts | 4 +--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/components/search/SearchWidget.vue b/components/search/SearchWidget.vue index 64e87878..8a008381 100644 --- a/components/search/SearchWidget.vue +++ b/components/search/SearchWidget.vue @@ -36,16 +36,18 @@ watch([results, focused], () => index.value = -1) const shift = (delta: number) => index.value = (index.value + delta % results.value.length + results.value.length) % results.value.length const activate = () => { - (document.activeElement as HTMLElement).blur() 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) - // router.push(`/search?q=${query.value}`) + if (currentIndex === -1) + // router.push(`/search?q=${query.value}`) + return router.push(results.value[currentIndex].to) } diff --git a/composables/masto/search.ts b/composables/masto/search.ts index e48f4519..ed98f3ab 100644 --- a/composables/masto/search.ts +++ b/composables/masto/search.ts @@ -57,9 +57,7 @@ export function useSearch(query: MaybeRef, options?: UseSearchOptions) { } watch(() => unref(query), () => { - if (!unref(query) || !isMastoInitialised.value) - return - loading.value = true + loading.value = !!(unref(query) && isMastoInitialised.value) }) debouncedWatch(() => unref(query), async () => {