MatBlazor icon indicating copy to clipboard operation
MatBlazor copied to clipboard

click on Links doesn't scroll to top on MatBlazor's demo site

Open Alienroid opened this issue 4 years ago • 7 comments

Describe the bug This can be reproduced on matblazor's website.

Click on new link, scroll position should reset to the top and not keeping previous page's scroll position. This happens when link is contained within MatDrawerContainer's MatDrawerContent

Solution: {edit: removed, the suggestion solution will cause side-effects}

To Reproduce Steps to reproduce the behavior:

  1. Go to 'https://www.matblazor.com/', open the drawer
  2. Click on {any link}
  3. Scroll down to 'the bottom'
  4. Click on {another link}
  5. Issue: scroll position is reserved from the previous page. Expected behavior: page should scroll to the top

Blazorfiddle link mock code: just the demo code: https://github.com/SamProf/MatBlazor/blob/master/src/MatBlazor.Demo/Shared/MainLayout.razor

Expected behavior page should scroll to the top

Screenshots

Additional context

Alienroid avatar Jun 04 '20 07:06 Alienroid

Interesting bug. It doesn't appear to be anything with the NavLink. Definitley a bug. What are you thoughts on a solutions?

enkodellc avatar Jul 06 '20 14:07 enkodellc

Any update on this?

vallgrenerik avatar May 03 '21 11:05 vallgrenerik

I have not looked at it. Happens in https://blazorboilerplate.com/ as well.

enkodellc avatar May 03 '21 16:05 enkodellc

@SamProf do you have any ideas?

vallgrenerik avatar May 18 '21 14:05 vallgrenerik

This seems to be a Blazor specific issue that was resolved. Maybe you can take a look and sort out what is going on from there;

https://github.com/dotnet/aspnetcore/issues/10482

enkodellc avatar May 18 '21 15:05 enkodellc

This seems to be a Blazor specific issue that was resolved. Maybe you can take a look and sort out what is going on from there;

dotnet/aspnetcore#10482

Thanks but I cant figure it out. Is it possible to write JS to navigate to top of page? When I try this for example: https://www.syncfusion.com/faq/blazor/javascript-interop/how-do-i-scroll-to-the-top-position-in-a-blazor-page document.documentElement.scrollTop and document.body.scrollTop is always 0. Any ideas?

vallgrenerik avatar May 18 '21 15:05 vallgrenerik

Okey I think I found something: When I use a <MatDrawerContainer Style="height: 100vh; width: 100vw;" Class="mat"> the problem is there.

But when I remove height: 100vh it works as expected.

vallgrenerik avatar May 18 '21 15:05 vallgrenerik