Ionic version: (check one with "x")
[ ] 1.x
[X] 2.x
I'm submitting a ... (check one with "x")
[X] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or http://ionicworldwide.herokuapp.com/
Current behavior:
When use navPop, navCtrl.pop() or viewCtrl.dismiss() on modal page don't fire ionViewDidEnter in previous page.
Expected behavior:
After close a modal fire ionViewDidEnter in previous page
Steps to reproduce:
http://plnkr.co/edit/fhMFXXdq3axa6Fz3b3vD
Other information:
https://github.com/driftyco/ionic/issues/9832
https://github.com/driftyco/ionic/issues/7847
Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):
Cordova CLI: 6.5.0
Ionic Framework Version: 2.1.0
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 1.0.0
ios-deploy version: 1.9.0
ios-sim version: 5.0.8
OS: OS X El Capitan
Node Version: v6.5.0
Xcode version: Xcode 8.2.1 Build version 8C1002
This started happening in the RC Builds. I've faced this many times, and now just use on dismiss callbacks and check the data returned from the modals dismiss.
@davec21 me too.
That seems to be the expected behaviour to me, the dismiss callback is there for your use case.
@davec21:
I've faced this many times, and now just use on dismiss callbacks [...]
I'd very much prefer using ionViewWillEnter() because it's a more central place that works in all scenarios. It's independent from leaving a page or leaving a modal and when I'm using several modals I don't have to hook up every modal separately.
@Iyashu5040:
That seems to be the expected behaviour to me, the dismiss callback is there for your use case.
There was a bug with this issue occurring in version 2.rc0 #8543 that had been fixed. Therefore I hope it's not intended ;).
@alex-pl
https://github.com/driftyco/ionic/issues/8543 i might misunderstood the bug, but this is the expected behaviour.
Pushing a modal, an alert, action-sheet, datetime (all them are the same thing) does not change the current page in the navigation stack, so no lifecycle must be called.
@manucorporat
Ok, this point of view totally makes sense, thanks for clarification.
Nevertheless, do you think there's a chance that events, similar to Android life cycles onResume() and onPause() could be implemented in the future?
The Android life cycle has the methods onStart() and onStop(). These two methods are about the same as ionViewWillEnter() and ionViewWillLeave().
I think it would be really great to have methods that are called when ionViewWillEnter()/ionViewWillLeave() are called and additionally in all those cases you are naming. This would be the same behavior as onResume() and onPause() on Android.
Having those methods would be helpful in many situations, for example:
Of course, those events could be implemented by listening to callbacks - but if you're using many alerts, modals, action sheets and other stuff, it's a hard job implementing it every time for all of these. Having a central way to handle this situations also prevents the developer from doing mistakes, like forgetting to hook up one of those components.
I really think this is a place where native Android developers have a little more choice and I really think this shouldn't be a thing Ionic developers should be jealous for, especially because it's a feasible future :).
Feel free to use this to create a new issue if you agree, or let me know whether I have a chance and should create it ;).
Reference for onPause() and the the Android activity life cycle: https://developer.android.com/guide/components/activities/activity-lifecycle.html#onpause
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.
Most helpful comment
@manucorporat
Ok, this point of view totally makes sense, thanks for clarification.
Nevertheless, do you think there's a chance that events, similar to Android life cycles
onResume()andonPause()could be implemented in the future?The Android life cycle has the methods
onStart()andonStop(). These two methods are about the same asionViewWillEnter()andionViewWillLeave().I think it would be really great to have methods that are called when
ionViewWillEnter()/ionViewWillLeave()are called and additionally in all those cases you are naming. This would be the same behavior asonResume()andonPause()on Android.Having those methods would be helpful in many situations, for example:
Of course, those events could be implemented by listening to callbacks - but if you're using many alerts, modals, action sheets and other stuff, it's a hard job implementing it every time for all of these. Having a central way to handle this situations also prevents the developer from doing mistakes, like forgetting to hook up one of those components.
I really think this is a place where native Android developers have a little more choice and I really think this shouldn't be a thing Ionic developers should be jealous for, especially because it's a feasible future :).
Feel free to use this to create a new issue if you agree, or let me know whether I have a chance and should create it ;).
Reference for onPause() and the the Android activity life cycle: https://developer.android.com/guide/components/activities/activity-lifecycle.html#onpause