From 5b57640949302d2eab08f94fad7a7879783c52e9 Mon Sep 17 00:00:00 2001 From: Leo Vasanko Date: Mon, 25 May 2026 15:32:33 +0000 Subject: [PATCH] fix: clicking search result no longer redirects to category page When clicking a search result, showDetail navigates to the detail page. The route.fullPath watcher then clears searchQuery, which propagates to Header's localSearch watcher, which emits @search='', which calls updateSearchQuery(''). This in turn called clearSearch(), which did a router.replace() to the category page because it didn't check whether the current route actually had a search query. The fix: in clearSearch(), if there's no search query in the current URL, just clear reactive state and return without navigating. This breaks the circular flow that was overwriting the detail-page navigation. --- frontend/src/App.vue | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 762dff6..bb173b0 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -438,7 +438,16 @@ function clearSearch(options: { preferBack?: boolean; targetPath?: string } = {} searchQuery.value = "" - if (!currentQuery && route.path === targetPath) { + // If there's no active search query in the URL, just clear state and don't navigate. + // This prevents unwanted navigation when the search is cleared reactively (e.g. + // route changes to a detail page, which triggers the route watcher to clear + // searchQuery, which flows through Header and back to updateSearchQuery). + if (!currentQuery) { + searchReturnPath.value = null + return + } + + if (route.path === targetPath) { searchReturnPath.value = null return } @@ -449,7 +458,6 @@ function clearSearch(options: { preferBack?: boolean; targetPath?: string } = {} : "" const canRestoreWithBack = options.preferBack !== false && - !!currentQuery && searchReturnPath.value === targetPath && backPath === targetPath