mirror of
https://github.com/filamentphp/filament.git
synced 2026-09-24 15:42:09 +08:00
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:
co-authored by
Dan Harrin
parent
5d509911b2
commit
30ff8731a4
Vendored
+1
-1
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,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'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user