Blazor: Let browser handle hash change #52583
Labels
api-suggestion
Early API idea and discussion, it is NOT ready for implementation
area-blazor
Includes: Blazor, Razor Components
bug
This issue describes a behavior which is not expected - a bug.
Milestone
Background and Motivation
As I can see there are 3 cases with hash:
a. Navigate to a hash on a different page. That was addressed in #8393
b. Blazor uses hash for page navigation. That is #6175 .
c. Navigate to a hash on the current page.
This request is to address the latter.
As I can see there are 3 behaviors that a developer might want:
popstate
orhashchange
and handle navigation event via javascript.The current behavior for
blazor.web.js
is pretty broken IMHO: Blazor makes a full intercept and a full SSR and then uses the feature from #8393 to navigate to the element.From the point of view of Blazor 1 and 2 are identical in the fact that if Blazor does nothing, that is the default browser behavior.
Proposed API
Add
ignoreHashNavigationOnSamePage
toSsrStartOptions
.Alternatively, respect
<meta name="ignoreHashNavigationOnSamePage" />
(or something similar), so the individual page can handle it through<HeadContent>
.Alternatively, my preferred behavior: make it the default (It makes no sense to do a SSR on same-page hash change).
Risks
There might be someone somewhere that actually reads url hash server-side.
The text was updated successfully, but these errors were encountered: