Skip to content
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

NavigateTo does not scroll to the top in internal navigation to same url #60190

Merged
merged 2 commits into from
Feb 6, 2025

Conversation

ilonatommy
Copy link
Member

@ilonatommy ilonatommy commented Feb 4, 2025

NavigateTo does not scroll to the top in internal navigation to same url

Description

If we use NavigateTo with same url as the current one or with only query appended, the navigation action finishes with setting the scroll at the top of the page. It happens even if we were not forcing the external navigation (setting forceLoad=false).

The change:
Now, we are conditioning the scroll action with the check if internal navigation is not happening for the same path. isForSamePath compares ignoring queries.

Fixes #40190

@ilonatommy ilonatommy self-assigned this Feb 4, 2025
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-blazor Includes: Blazor, Razor Components label Feb 4, 2025
@ilonatommy ilonatommy marked this pull request as ready for review February 4, 2025 17:01
@ilonatommy ilonatommy requested a review from a team as a code owner February 4, 2025 17:01
@ilonatommy ilonatommy requested a review from oroztocil February 5, 2025 09:35
Copy link
Member

@javiercn javiercn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@ilonatommy ilonatommy merged commit a55c4bd into dotnet:main Feb 6, 2025
27 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the 10.0-preview2 milestone Feb 6, 2025
@ilonatommy
Copy link
Member Author

I realized that this fixes the problem only for client side routing. In case of external navigation, the issue is still there, @javiercn. This problem will be added to #51646.

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 feature-blazor-navigation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Blazor NavigationManager.NavigateTo always scrolls page to the top.
2 participants