Inconsistent lifecycle events when working with modals
Short description of the problem:
When I'm on page P and I open the modal M, P will fire the lifecycle events onPageWillLeave and onPageDidLeave, and then M will fire onPageWillEnter and onPageDidEnter. When I'm dismissing M, it will fire onPageWillLeave and onPageDidLeave, but P wont fire any lifecycle events.
What behavior are you expecting?
I would expect P to fire onPageWillEnter and onPageDidEnter.
Which Ionic Version? 2.x
Run ionic info from terminal/cmd prompt: (paste output below)
Cordova CLI: 6.1.0 (cordova-lib@undefined)
Gulp version: CLI version 3.9.0
Gulp local: Local version 3.9.1
Ionic Version: 2.0.0-beta.3
Ionic CLI Version: 2.0.0-beta.19
Ionic App Lib Version: 2.0.0-beta.9
OS: Windows 7 SP1
Node Version: v5.7.0
Hey @schlaus ! Thanks for opening an issue with us! Would you be able to make a codepen or plunker that demonstrates this issue?
Hello all! As it seems it has been a while since there was any activity on this issue i will be closing it for now. Feel free to comment if you are still running into this issue. Thanks for using Ionic!
same issue. creating modal like this:
let modal = Modal.create(NewTicketPage);
this.nav.present(modal);
normally the lifecycle onPageWillEnter() works perfect with all the other pages.
the modal itself is also a page btw. so nothing special there.
but since this sounds like a big issue, i do not know whether i did a mistake.
the constructor itself is called everytime it should be called.
edit:
Your system information:
Cordova CLI: You have been opted out of telemetry. To change this, run: cordova telemetry on.
6.2.0
Ionic Framework Version: 2.0.0-beta.7
Ionic CLI Version: 2.0.0-beta.29
Ionic App Lib Version: 2.0.0-beta.16
OS: Distributor ID: Fedora Description: Fedora release 23 (Twenty Three)
Node Version: v5.10.1
edit2: well...after updating to the latest ionic beta everything is fine now...should have done it in the first place. also the renaming was important.
Your system information:
Cordova CLI: 6.2.0
Ionic Framework Version: 2.0.0-beta.9
Ionic CLI Version: 2.0.0-beta.29
Ionic App Lib Version: 2.0.0-beta.16
OS: Distributor ID: Fedora Description: Fedora release 23 (Twenty Three)
Node Version: v5.10.1
This seems to be an issue again on current master (ccf6ae5) with ModalController:
let modal = this.modalCtrl.create(ReportDetailsPage, {report: report})
modal.present();
and later dismissing the modal
this.viewCtrl.dismiss(this.report);
ionViewWillEnter will not be called.
Is there a workaround in Beta 11 until this is fixed, perhaps to manual way to fire or subscribe to the ionViewWillEnter and ionViewDidEnter events?
All my views are populated according to the ViewController lifecycle, using the ionViewWillEnter and ionViewDidEnter events, so would rather not refactor that code if this will be fixed in an upcoming beta.
Note, the ionViewLoaded event is still being fired when using the ModalController, just not the other lifecycle events.
Ok, this is strange, but if I override the showBackdrop and enableBackdropDismiss options, then the modal fires the ionViewWillEnter and ionViewDidEnter events as expected.
let modal = this.modalController.create(ModalPage,
{},
{ showBackdrop: false, enableBackdropDismiss:false });
modal.present();
Perhaps a workaround until this issue has been fixed...
I am using @dalezak 's workaround ATM. (I don't want to know what they had to do to arrive at this workaround. 😬) I am using a view that can be called from many places in the app, so it really needs to be a "modal." [RC4] Setting those options works for me on those specific modals, as this is only "phone"-sized devices. After adding those options, I am getting expected results from dismissing the modal and re-entering it.
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.