mirror of
https://github.com/tiennm99/HugoBlox-kit.git
synced 2026-10-20 02:16:40 +00:00
fix: browser back button after searching does not behave properly
Switch URL updating strategy from pushState to replaceState in order to avoid pushing all search queries to the browser history Fix #1166
This commit is contained in:
1 parent
bb3d35133e
commit
e4f0e80dfb
2 files changed
+4
-4
No files matched your search
@@ -43,8 +43,8 @@ function getSearchQuery(name) {
|
|||||||
|
|
||||||
// Set query in URI without reloading the page.
|
// Set query in URI without reloading the page.
|
||||||
function updateURL(url) {
|
function updateURL(url) {
|
||||||
if (history.pushState) {
|
if (history.replaceState) {
|
||||||
window.history.pushState({path:url}, '', url);
|
window.history.replaceState({path:url}, '', url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,9 +50,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function removeQueryParamsFromUrl() {
|
function removeQueryParamsFromUrl() {
|
||||||
if (window.history.pushState) {
|
if (window.history.replaceState) {
|
||||||
let urlWithoutSearchParams = window.location.protocol + "//" + window.location.host + window.location.pathname + window.location.hash;
|
let urlWithoutSearchParams = window.location.protocol + "//" + window.location.host + window.location.pathname + window.location.hash;
|
||||||
window.history.pushState({path:urlWithoutSearchParams}, '', urlWithoutSearchParams);
|
window.history.replaceState({path:urlWithoutSearchParams}, '', urlWithoutSearchParams);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user