Update search text with search query

This commit is contained in:
guemax 2024-07-12 10:24:45 +02:00
parent 8fe663da80
commit 475f645a1e
No known key found for this signature in database
GPG key ID: 85916548E34D20A0

View file

@ -152,14 +152,22 @@ export default {
return _this.getPreferenceBoolean("searchHistory", false) && localStorage.getItem("search_history"); return _this.getPreferenceBoolean("searchHistory", false) && localStorage.getItem("search_history");
}, },
}, },
watch: {
$route() {
this.updateSearchTextFromURLSearchParams();
},
},
mounted() { mounted() {
this.fetchAuthConfig(); this.fetchAuthConfig();
const query = new URLSearchParams(window.location.search).get("search_query"); this.updateSearchTextFromURLSearchParams();
if (query) this.onSearchTextChange(query);
this.focusOnSearchBar(); this.focusOnSearchBar();
this.homePagePath = this.getHomePage(this); this.homePagePath = this.getHomePage(this);
}, },
methods: { 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 // focus on search bar when Ctrl+k is pressed
focusOnSearchBar() { focusOnSearchBar() {
hotkeys("ctrl+k", event => { hotkeys("ctrl+k", event => {