[release/8.0] [Blazor] Avoid fetching new page content when only the hash changes #53542
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.
Avoid fetching new page content when only the hash changes
Backport of #53341
Fixes an issue where a page request is made after clicking a link that only updates the hash part of the URL.
Description
The PR fixes the bug by updating the behavior to match what browsers do by default - if the hash is the only part of the URL that changes, scroll to the element with the ID of the new hash.
This was already implemented correctly for interactive routing, so this PR updates enhanced navigation to share the same logic.
Fixes #52583
Customer Impact
Customers' apps may behave unexpectedly by making full page requests rather than scrolling to a location on an already-loaded page. This is inconsistent with the interactive routing behavior, which correctly handles scrolling to elements via hash URL.
Regression?
Enhanced navigation is a new feature in .NET 8, and this bug has existed since the feature was introduced.
Risk
Most of the changes are moving the "scroll to hash" logic to a location that can be shared between enhanced navigation and interactive routing. The only new logic introduced is that which allows the enhanced navigation logic to hook into that shared behavior.
Verification
Packaging changes reviewed?