#Router navigation doesn't scroll to top

1 messages · Page 1 of 1 (latest)

severe lava
#

When navigating via the Angular router (Angular 19, standalone router), the new page doesn't start at the top. The scroll position stays where I clicked the link. I've tried withInMemoryScrolling / scrollPositionRestoration, Router.events with NavigationEnd + window.scrollTo, and manually scrolling a container via @ViewChild, but nothing works. Can you please help me ?

keen heron
#

withInMemoryScrolling({ scrollPositionRestoration: 'enabled' })
Works out of the box. But. Only with window's scroll.

manually scrolling a container via @ViewChild
If you are not using window's scroll, i.e. some prefers body height to be ~calc(100% - toolbarPx); overflow-y: auto, then: you need to provide a custom ViewportScroller

severe lava