ChangeDetection is not reenabled on active tab when returning to Tabs page, and ionViewDidEnter is also not fired on active tab page.
Short description of the problem:
If you push a page in tabs.ts, and later return - the changedetection in the active tab page is not reenabled, and lifecycle events such as ionViewDidEnter is also not fired.
Steps to reproduce: Run my plunker link, open console to see log events from ionViewDidEnter. Push the tab called "Push" and close it again and notice the counter is no longer updating.
Which Ionic Version? 1.x or 2.x 2.beta.10
Plunker that shows an example of your issue
http://plnkr.co/edit/4gOLUPs3Doyf3Twz0qjA?p=preview
Note for self and team: http://plnkr.co/edit/Yrvj6SL9gQTsRb2TIHqn?p=preview As this plunker shows, pushing a page in a tabs app is working fine, so this issue seems to be isolated to the use case of pushing a page by clicking on a tab.
I just wanted to add that if you change your goToPage1 method in your plunker to use rootNav, the lifecycle events will not fire when returning, but changedetection does seem to work in this case.
goToPage1() {
this.nav.rootNav.push(Page1);
}
Hello @andersfa87 Is this still an issue with beta.11? Thanks!
Hey @jgw96 Yeah, both problems are still there.
Any workaround I can use to manually start tracking changes again? Stuff like pull to refresh is quite broken when change detection is not running :)
@andersfa87 Sorry for the delay on this. Is their any way that you could push your page from a button instead of from clicking on a tab? Their is a separate issue open about doing other events besides navigating to a tab by clicking on a tab, but at this time it is recommended to only use tabs to navigate to a different tab (as they are in our tabs starter) and not to push a page or do other actions.
Hey @jgw96
I work with andersfa87, so I can give you some more info about the problem we experience.
The problem is not only when you click on the tabs.
Every tab has an active view/component. If you on this active view (let us call it view1) use a normal button and push another view (view2) to the rootNav (thereby replacing tabs with view2), then ionViewWillEnter and ionViewDidEnter are not fired on view1 when returning (click back).
ionViewWillEnter and ionViewDidEnter are only fired on the tabs page/component.
From a technical aspect it makes sense that when returning to the tab, the events are fired in tabs. But the user actually returns to the active view in the tab and therefore we need the possibility to update the content of the view.
up! need too, no sense to not fired ionViewWillEnter when change tabs active page
Hey @jgw96, was this fixed? I'm still having the exact issue described by @rasmusl7 above.
Same, getting this issue here trying to get animations to activate based on tab changes.
Still getting this. I don't think it's fixed.
A temporary fix that resolved it for our team was to call this.appRef.tick() in ionViewWillLeave.
The only issue we're facing is that the change detection is not being triggered if you go between tabs which you've already visited before. Any new page or tab is fine. All ionView... callbacks are being triggered properly, just not the model changes.
Adding this.appRef.tick() worked for us, thanks @emiljohansson
in src/components/tabs/tab.ts there is no emit for view events on selected in L364, maybe, we can submit a patch for that and raise view event ?
/**
* @hidden
*/
setSelected(isSelected: boolean) {
this.isSelected = isSelected;
this.setElementClass('show-tab', isSelected);
this.setElementAttribute('aria-hidden', (!isSelected).toString());
if (isSelected) {
// this is the selected tab, detect changes
this._cd.reattach();
this.viewWillEnter.emit();
} else {
// this tab is not selected, do not detect changes
this._cd.detach();
this.viewWillLeave.emit();
}
}
Same issue here
Got the issue too, when pushing a view to rootNav from tabs, and getting back to it with back button, only the tab component hooks are fired, not the view selected, a little bit annoying I need to refresh datas (in active view in tabs component) and I don't want to bypass it with custom events...
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.