Skip to content

Commit fc2e05e

Browse files
committed
Missing change to the backwards/forwards fix commit.
1 parent d56bc30 commit fc2e05e

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/Components/Web.JS/src/Services/NavigationEnhancement.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,7 @@ function performProgrammaticEnhancedNavigation(absoluteInternalHref: string, rep
8888
}
8989
}
9090

91-
function getCurrentScrollPosition()
92-
{
91+
function getCurrentScrollPosition() {
9392
const scrollPositionX = window.scrollX;
9493
const scrollPositionY = window.scrollY;
9594
return { X: scrollPositionX, Y: scrollPositionY };
@@ -98,9 +97,9 @@ function getCurrentScrollPosition()
9897
function saveScrollPosition() {
9998
const currentState = history.state || {};
10099
const scrollPosition = getCurrentScrollPosition();
101-
// save the current scroll position
102-
const updatedState = { ...currentState, scrollPosition: scrollPosition };
103-
history.replaceState(updatedState, /* ignored title */ '', location.href);
100+
// save the current scroll position
101+
const updatedState = { ...currentState, scrollPosition: scrollPosition };
102+
history.replaceState(updatedState, /* ignored title */ '', location.href);
104103
}
105104

106105
function onDocumentClick(event: MouseEvent) {
@@ -139,9 +138,9 @@ function onPopState(state: PopStateEvent) {
139138
}
140139

141140
// load the new page
141+
const scrollPosition = history.state?.scrollPosition;
142142
saveScrollPosition();
143143
performEnhancedPageLoad(location.href, /* interceptedLink */ false).then(() => {
144-
const scrollPosition = history.state?.scrollPosition;
145144
if (scrollPosition !== undefined &&
146145
(scrollPosition.X !== window.scrollX || scrollPosition.Y !== window.scrollY)) {
147146
window.scrollTo(scrollPosition.X, scrollPosition.Y);

0 commit comments

Comments
 (0)