Skip to content

Commit 9eec3f0

Browse files
committed
fix(docs[spa-nav]): always navigate on popstate to fix back-button content update
why: The popstate handler guarded on `e.state && e.state.spa`, but browsers can deliver null state for the initial history entry even after replaceState({spa: true}). This caused three symptoms: - Back button changed URL but didn't update page content - Sidebar links resolved wrong after back-navigating across depths - Brand logo href went stale after SPA navigation what: - Remove state guard from popstate handler — always call navigate() - Safe: navigate() falls back to full page load on error, and isPop=true prevents pushing duplicate history entries
1 parent b318772 commit 9eec3f0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

docs/_static/js/spa-nav.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,8 @@
203203

204204
history.replaceState({ spa: true }, "");
205205

206-
window.addEventListener("popstate", function (e) {
207-
if (e.state && e.state.spa) navigate(location.href, true);
206+
window.addEventListener("popstate", function () {
207+
navigate(location.href, true);
208208
});
209209

210210
// --- Hover prefetch ---

0 commit comments

Comments
 (0)