Skip to content

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Oct 3, 2025

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:

  • Added the isHashOnlyChange utility function in NavigationUtils.ts to detect when a navigation event only changes the hash fragment, avoiding unnecessary page loads.
  • Updated the onPopState handler in NavigationEnhancement.ts to use isHashOnlyChange, preventing enhanced navigation logic from running when only the hash changes.
  • Added a new end-to-end test in 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?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

The fix is limited to same-page navigation on elements that have enhanced navigation explicitly disabled.

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

@lewing lewing added Servicing-approved Shiproom has approved the issue and removed Servicing-consider Shiproom approval is required for the issue labels Oct 3, 2025
@lewing
Copy link
Member

lewing commented Oct 3, 2025

approved in email

@wtgodbe wtgodbe merged commit 89f8531 into release/10.0 Oct 3, 2025
28 checks passed
@wtgodbe wtgodbe deleted the backport/pr-63449-to-release/10.0 branch October 3, 2025 16:10
@dotnet-policy-service dotnet-policy-service bot modified the milestone: 10.0.0 Oct 3, 2025
wtgodbe added a commit that referenced this pull request Oct 3, 2025
….0 (#63920)

[release/10.0] Fix fetch request in data-enhance-nav="false" for same-page anchors

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-blazor Includes: Blazor, Razor Components Servicing-approved Shiproom has approved the issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants