-
Notifications
You must be signed in to change notification settings - Fork 10.3k
[Blazor] Scroll position persists during page navigation. #10482
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
I have seen this many times. I agree that it is more natural to display a new page from the beginning. Current behaviour is especially confusing when you have a few pages with different length. From the point of view of app user each page is displayed with random scroll position. |
Not pushing out of preview8, as this will result in behavior breaking change |
For those who want to see this annoying behaviour I have found a demo of Blazor Strap here: https://chanan.github.io/BlazorStrap/ I was thinking a little bit about this and the problem is that people can design sophisticated layouts to create an impression that Blazor app is like a desktop app. To achieve this they can use flexbox, flexgrid, static/absolute positioning or other techniques. So the question is: for which HTML element should we reset vertical scroll position after navigation? I think that we should start searching from the first element in the layout which contains If it is not easy or doesn't provide expected results in all possible layouts we should be able to configure application manually to reset vertical scroll position in specified element after each navigation. This element can potentially change at runtime if we have more than one layout defined in an application. |
Done in #12423 |
Describe the bug
When navigating from page to page, the scroll position is persisted instead of resetting.
To Reproduce
Page1.razor
, then paste the following code on the page:Page2.razor
, then paste the following code on the page:Page1
and scroll all the way down until you see theGo to page 2
link.Go to page 2
link.The correct behavior (in my opinion) should be for Page2 scroll position to be at the top of the page. Instead, Page2 is scrolled down to the same scroll position Page1 was.
This happens at least in Chrome and Edge.
The text was updated successfully, but these errors were encountered: