From 475f645a1e6949e758175b4eaadd429f56ce3619 Mon Sep 17 00:00:00 2001 From: guemax Date: Fri, 12 Jul 2024 10:24:45 +0200 Subject: [PATCH] Update search text with search query --- src/components/NavBar.vue | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/components/NavBar.vue b/src/components/NavBar.vue index 85764d1e..0e7fc6ec 100644 --- a/src/components/NavBar.vue +++ b/src/components/NavBar.vue @@ -152,14 +152,22 @@ export default { return _this.getPreferenceBoolean("searchHistory", false) && localStorage.getItem("search_history"); }, }, + watch: { + $route() { + this.updateSearchTextFromURLSearchParams(); + }, + }, mounted() { this.fetchAuthConfig(); - const query = new URLSearchParams(window.location.search).get("search_query"); - if (query) this.onSearchTextChange(query); + this.updateSearchTextFromURLSearchParams(); this.focusOnSearchBar(); this.homePagePath = this.getHomePage(this); }, methods: { + updateSearchTextFromURLSearchParams() { + const query = new URLSearchParams(window.location.search).get("search_query"); + if (query) this.onSearchTextChange(query); + }, // focus on search bar when Ctrl+k is pressed focusOnSearchBar() { hotkeys("ctrl+k", event => {