ionic-framework
ionic-framework copied to clipboard
bug: ion livecycles are not called as expected on nested ion-router-outlet, also caching algorithm has strange behavior
Bug Report
Ionic version: [x] 4.2
Current behavior:
If you have nested ion-router-outlet ionView* live cycles are not called as expected for nested pages, there are several issues on it. We tried to figure out all of them, and we created a plain github repository for you to simulate all them.
What to know is we have a main router which keeps login and main page, and the main pages keeps the dashboard page with :id parameter s like this
login
--->
main ----> dashboard/:id
1)
if you enter first time using login button to /main/dashboard/1 page Nested DashboardPage live cycles are called before the MainPage live cycles for entering.
We think the right behavior should be LoginPage#willLeave -> MainPage#willEnter -> DashboardPage#willEnter -> DashboardPage#didEnter -> MainPage#didEnter -> LoginPage#didLeave
2)
now if you switch to dashboard/2 we have this log
which is the right one, But what we can see from html, there is a strange behavior how does the ReuseStratgey work. the first /dashboard/1 page is always cached, other pages not. Why not? There is a difference on caching pages with and without parameters. But the livecycles are called in the right order.
3)
if you know clicks on logout you are redirect to login page and have this log
As you can see DashboardPage livecycles are never called! Only that for MainPage and LoginPage. But DashboardPage#ionWillLeave and DashboardPage#ionDidLeave should be called in the right order
4)
now on login page click again Login and you are redirected again to /main/dashboard/1
And as you can see from log, NOW when the dashboard page is already cached the livecycles are called as expected, not as on use case 1) where page was not cached.
Steps to reproduce: We have created a project to simulate the issues https://github.com/mburger81/ionic4-nested-router
Ionic info:
Ionic:
ionic (Ionic CLI) : 4.12.0 (/usr/lib/node_modules/ionic)
Ionic Framework : @ionic/angular 4.2.0
@angular-devkit/build-angular : 0.13.8
@angular-devkit/schematics : 7.2.4
@angular/cli : 7.3.8
@ionic/angular-toolkit : 1.4.1
System:
NodeJS : v10.15.3 (/usr/bin/node)
npm : 6.9.0
OS : Linux 4.15