Skip to content

Commit 8da794c

Browse files
committed
Fix: backwards/forwsrds button, preserve scroll position.
1 parent 06655d5 commit 8da794c

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,14 @@ export function detachProgressivelyEnhancedNavigationListener() {
7272
}
7373

7474
function performProgrammaticEnhancedNavigation(absoluteInternalHref: string, replace: boolean) : void {
75+
let isSelfNavigation = isForSamePath(absoluteInternalHref, location.href);
76+
7577
performEnhancedPageLoad(absoluteInternalHref, /* interceptedLink */ false);
7678

79+
if (!isSelfNavigation) {
80+
resetScrollAfterNextBatch();
81+
}
82+
7783
// history update should be the last step - same as in client side routing
7884
if (replace) {
7985
history.replaceState(null, /* ignored title */ '', absoluteInternalHref);
@@ -205,7 +211,6 @@ export async function performEnhancedPageLoad(internalDestinationHref: string, i
205211
},
206212
}, fetchOptions));
207213
let isNonRedirectedPostToADifferentUrlMessage: string | null = null;
208-
let forSamePath = isForSamePath(internalDestinationHref, currentContentUrl);
209214
await getResponsePartsWithFraming(responsePromise, abortSignal,
210215
(response, initialContent) => {
211216
const isGetRequest = !fetchOptions?.method || fetchOptions.method === 'get';
@@ -328,9 +333,6 @@ export async function performEnhancedPageLoad(internalDestinationHref: string, i
328333
const targetElem = document.getElementById(hash);
329334
targetElem?.scrollIntoView();
330335
}
331-
else if (!forSamePath) {
332-
resetScrollAfterNextBatch();
333-
}
334336

335337
performingEnhancedPageLoad = false;
336338
navigationEnhancementCallbacks.enhancedNavigationCompleted();

0 commit comments

Comments
 (0)