Skip to content

Commit 667317b

Browse files
authored
Prevent replacing history state when scroll regions are unchanged (#2629)
1 parent 7c6a086 commit 667317b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

packages/core/src/history.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { isEqual } from 'lodash-es'
12
import { decryptHistory, encryptHistory, historySessionStorageKeys } from './encryption'
23
import { page as currentPage } from './page'
34
import Queue from './queue'
@@ -106,6 +107,10 @@ class History {
106107
return
107108
}
108109

110+
if (isEqual(this.getScrollRegions(), scrollRegions)) {
111+
return
112+
}
113+
109114
return this.doReplaceState({
110115
page: window.history.state.page,
111116
scrollRegions,
@@ -121,6 +126,10 @@ class History {
121126
return
122127
}
123128

129+
if (isEqual(this.getDocumentScrollPosition(), scrollRegion)) {
130+
return
131+
}
132+
124133
return this.doReplaceState({
125134
page: window.history.state.page,
126135
documentScrollPosition: scrollRegion,

0 commit comments

Comments
 (0)