-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Description
Bug 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 angular/angular#24547).