Fix browser navigation throttling issues (#17911)

* Fix browser navigation issues in SPA mode

* Fix browser navigation issues in SPA mode

* Rebuild JS

* Clean up

* Update history-state.js

---------

Co-authored-by: Dan Harrin <git@danharrin.com>
This commit is contained in:
Raj Siva-Rajah
2025-09-24 18:01:49 +01:00
committed by GitHub
co-authored by Dan Harrin
parent 5d509911b2
commit 30ff8731a4
3 changed files with 29 additions and 1 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
@@ -0,0 +1,27 @@
const originalReplaceState = window.history.replaceState
const originalPushState = window.history.pushState
window.history.replaceState = function (state, unused, url) {
if (state?.url instanceof URL) {
state.url = state.url.toString()
}
// Skip duplicate `replaceState()` calls
try {
if (JSON.stringify(state) === JSON.stringify(window.history.state)) {
return
}
} catch (error) {
// If comparison fails, proceed with the update
}
originalReplaceState.call(window.history, state, unused, url)
}
window.history.pushState = function (state, unused, url) {
if (state?.url instanceof URL) {
state.url = state.url.toString()
}
originalPushState.call(window.history, state, unused, url)
}
+1
View File
@@ -1,6 +1,7 @@
import Mousetrap from '@danharrin/alpine-mousetrap'
import sidebar from './stores/sidebar.js'
import './dark-mode.js'
import './history-state.js'
import './scroll-sidebar.js'
import './unsaved-changes-alert.js'