forked from nostr/nostrweb
nav: add history entry only once onload
reloading the page always added a history entry breaking back button functionality. fixed by only adding a history entry on load if the history is empty, so that reloads will not add the same entry over and over again.
parent
cd7dfa3f19
commit
5ef45d93d3
|
@ -216,7 +216,11 @@ const route = (path: string) => {
|
||||||
|
|
||||||
// onload
|
// onload
|
||||||
route(location.pathname);
|
route(location.pathname);
|
||||||
|
|
||||||
|
// only push a new entry if there is no history onload
|
||||||
|
if (!history.length) {
|
||||||
history.pushState({}, '', location.pathname);
|
history.pushState({}, '', location.pathname);
|
||||||
|
}
|
||||||
|
|
||||||
window.addEventListener('popstate', (event) => {
|
window.addEventListener('popstate', (event) => {
|
||||||
route(location.pathname);
|
route(location.pathname);
|
||||||
|
|
Loading…
Reference in New Issue