@@ -72,8 +72,14 @@ export function detachProgressivelyEnhancedNavigationListener() {
7272}
7373
7474function 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