We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 21634da + 6f28385 commit 9ce5af9Copy full SHA for 9ce5af9
1 file changed
src/core/drive/history.ts
@@ -21,6 +21,8 @@ export class History {
21
started = false
22
pageLoaded = false
23
previousScrollRestoration?: ScrollRestoration
24
+ // This can be customized by the consumer
25
+ shouldRestore: (state: any) => boolean = () => true
26
27
constructor(delegate: HistoryDelegate) {
28
this.delegate = delegate
@@ -94,7 +96,7 @@ export class History {
94
96
onPopState = (event: PopStateEvent) => {
95
97
if (this.shouldHandlePopState()) {
98
const { turbo } = event.state || {}
- if (turbo) {
99
+ if (this.shouldRestore(event.state) && turbo) {
100
this.location = new URL(window.location.href)
101
const { restorationIdentifier } = turbo
102
this.restorationIdentifier = restorationIdentifier
0 commit comments