[release/10.0] Fix fetch request in data-enhance-nav="false" for same-page anchors #63915
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport of #63449 to release/10.0
/cc @ilonatommy @dariatiurina
Fix fetch request in data-enhance-nav="false" for same-page anchors
Fixes #55534.
Description
This pull request enhances the navigation logic to better handle hash-only changes in URLs, ensuring that navigation to anchors within the same page does not trigger a full page reload or unnecessary fetch requests. It introduces a utility function to detect hash-only changes and updates the navigation handler to leverage this, improving performance and user experience. Additional end-to-end tests and markup updates verify and demonstrate the new behavior.
Changes:
isHashOnlyChange
utility function inNavigationUtils.ts
to detect when a navigation event only changes the hash fragment, avoiding unnecessary page loads.onPopState
handler inNavigationEnhancement.ts
to useisHashOnlyChange
, preventing enhanced navigation logic from running when only the hash changes.EnhancedNavigationTest.cs
to verify that non-enhanced navigation to a hash does not trigger a page fetch, ensuring the scroll behavior works as expected without unnecessary network activity.Customer Impact
In the special cases for the same-page hash navigation without this bug fix the infinite cycle can occur. This prevents it. The fix is localized to the enhanced navigation.
Regression?
Risk
The fix is limited to same-page navigation on elements that have enhanced navigation explicitly disabled.
Verification
Packaging changes reviewed?