mirror of
https://github.com/TeamPiped/Piped.git
synced 2024-08-30 18:43:17 +00:00
fix: update search text and title when route changes (#3701)
This commit is contained in:
parent
1ae1688a82
commit
3c177a06ec
@ -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 => {
|
||||||
|
@ -56,6 +56,11 @@ export default {
|
|||||||
this.updateResults();
|
this.updateResults();
|
||||||
this.saveQueryToHistory();
|
this.saveQueryToHistory();
|
||||||
},
|
},
|
||||||
|
updated() {
|
||||||
|
if (this.$route.query.search_query !== undefined) {
|
||||||
|
document.title = this.$route.query.search_query + " - Piped";
|
||||||
|
}
|
||||||
|
},
|
||||||
activated() {
|
activated() {
|
||||||
this.handleRedirect();
|
this.handleRedirect();
|
||||||
window.addEventListener("scroll", this.handleScroll);
|
window.addEventListener("scroll", this.handleScroll);
|
||||||
|
Loading…
Reference in New Issue
Block a user