-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Enhanced Navigation does not scroll new page to top #51338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@oliverw thanks for contacting us. The behavior is deliberate. There are other situations where what you are suggesting results in a bad experience that enhanced navigation tries to improve. For example, when you scroll down to the bottom of a page and post a form. The browser will "reset" the scroll position, which forces the user to navigate all the way down. The "goal" of enhanced page navigations is to make the app feel like a SPA, and in such case, the expectation is that clicking a link won't change the scroll position. If you want to scroll to the top, you can either do it via JavaScript with |
Here is the script that I use: Blazor.addEventListener('enhancedload', () => {
window.scrollTo({ top: 0, left: 0, behavior: 'instant' });
}); |
Allright, fair enough. |
Is there an existing issue for this?
Describe the bug
I believe page navigation in a
Blazor Web App
should behave identical whether enhanced navigation is turned on or off. In RC2 the destination page will retain the scroll position of the originating page if enhanced navigation is active.Expected Behavior
No response
Steps To Reproduce
Create a
Blazor Web App
project using the default settings (no auth etc.)Change
Components/Pages/Home.razor
to this:Components/Pages/Weather.razor
between thePageTitle
component and theh1
:/
/weather
/weather
Exceptions (if any)
No response
.NET Version
8.0.100-rc.2.23502.2
Anything else?
No response
The text was updated successfully, but these errors were encountered: