Skip to content

Commit 4bb475c

Browse files
committed
fix(history): popstate goes to nothing pt.2 :)
1 parent 64ab6db commit 4bb475c

File tree

3 files changed

+3
-7
lines changed

3 files changed

+3
-7
lines changed

static/js/search.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function searchNoRealod(searchQuery) {
1414
(window.location.protocol + "//" + window.location.host).length,
1515
);
1616
window.location.prevPath = prevPath;
17-
window.history.pushState({ prevPath }, "", `/search?query=${query}`);
17+
window.history.pushState({}, "", `/search?query=${query}`);
1818
}
1919

2020
searchFormEl.addEventListener("submit", (e) => {

static/js/utils.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,7 @@ function getTextWidth() {
4141
window.addEventListener("popstate", (e) => {
4242
e.stopImmediatePropagation();
4343
e.preventDefault();
44-
if (history.state && history.state.prevPath) {
45-
window.open(history.state.prevPath, "_self");
46-
} else {
47-
window.open(window.location.prevPath, "_self");
48-
}
44+
window.open(window.location.prevPath, "_self");
4945
});
5046

5147
window.Utils = {

views/components/navlink/navlink.templ

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ templ NavLink(title, imageUrl, path string) {
1919
script updateHref(path string) {
2020
const prevPath = window.location.href.substring((window.location.protocol+"//"+window.location.host).length);
2121
window.location.prevPath = prevPath;
22-
window.history.pushState({ prevPath }, "", path)
22+
window.history.pushState({}, "", path)
2323
}

0 commit comments

Comments
 (0)