v4 scroll position is not restored
See original GitHub issueBug Report
Ionic Info
Ionic:
ionic (Ionic CLI) : 4.0.0-rc.9 (C:\Users\xxxx\AppData\Roaming\npm\node_modules\ionic)
Ionic Framework : @ionic/angular 4.0.0-alpha.7
@angular-devkit/core : 0.7.0-rc.0
@angular-devkit/schematics : 0.7.0-rc.0
@angular/cli : 6.1.0-rc.0
@ionic/ng-toolkit : 1.0.0-rc.9
@ionic/schematics-angular : 1.0.0-rc.9
System:
NodeJS : v10.5.0 (C:\Program Files\nodejs\node.exe)
npm : 5.2.0
OS : Windows 10
Describe the Bug The scroll position is not restored when navigating back from a page. If you scroll down a list and then navigate to a detail page and then hit the back button, the scroll position on the originating page is set back to [0, 0], basically loosing the context. This behaviour is really bad for the user experience.
Steps to Reproduce
- Run ionic serve
- On home page wait until the list loads and scroll down to e.g. to the last list entry.
- Click on the list entry and then navigate back from the detail page to the home page.
- After navigating back the scroll position is set to [0,0], the previously scroll state is not restored.
Related Code Example reproduction: https://github.com/coonmoo/IonicScrollPosBug
Expected Behavior The scroll position should be correctly restored when navigating back from a page.
Additional Context I tried to fix it with the latest Angular 6.1.0 feature of scrollPositionRestoration, but it does not seem to work. Angular’s ViewportScroller always reports [0,0] scroll position when navigating back. I suppose that is an Ionic issue, because using plain Angular it seems to work (see also https://github.com/angular/angular/issues/24547).
Issue Analytics
- State:
- Created 5 years ago
- Reactions:11
- Comments:11 (5 by maintainers)

Top Related StackOverflow Question
Hey yall, just chiming in on an update for this.
In 6.1 of ngRouter, there was a new API in place for restoring scroll position. Only issue is that the API used the document body to work with scrolling. While this works for typical Angular Apps, it does not work with nested scroll containers, like ion-content.
Similar to how we override the router
RouteReuseStrategyclass, we can do the same thing for theViewportScrollerAPI. This is what I’m working on currently and hope to have something to present soon.What is the latest status of this? Should I implement a ViewPortScroller or are you guys at Ionic working on a solution?