ionic-framework: ionViewCanLeave lifecycle hook on Tabs page - error with ion-segments
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:
I believe this to be a bug, although you may correct me if I am wrong: using an ionViewCanLeave() lifecycle hook on a tabs page which implements ion-segments seems to cause the ion-segment-buttons to stop operating after rejecting the promise.
E.g. I have a tab button hooked up to a logout button with an ionSelect implemented. This ionSelect fires my logout logic (which pops the page). After tapping “No” to confirm if I want to log out, the ion-segment seems to be inoperable.
This seems to be the case when the hook is implemented on the main tabs TypeScript file.
Expected behavior:
For the ion-segment to continue working, after rejecting the promise returned in ionViewCanLeave.
Steps to reproduce:
- Clone the following repository: https://github.com/kelvindart/ionic2-tabs-lifecycle.
mkdir wwwso Ionic/Cordova recognises it as a Cordova project.- Run
npm install. - Run
ionic serve. - Tap “Go to Tabs”.
- Tap “Log out”.
- Tap “No”.
- Attempt to tap each segment, observe the
[ngSwitch]does not operate.
Related code:
ionViewCanLeave() {
return new Promise((resolve, reject) => {
let alert = this.alertCtrl.create({
title: 'Log out',
subTitle: 'Are you sure you want to log out?',
buttons: [
{
text: 'No',
role: 'cancel',
handler: () => {
reject();
}
},
{
text: 'Yes',
handler: () => {
alert.dismiss().then(() => {
resolve();
});
}
}
]
});
alert.present();
});
Other information: N/A
Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):
Cordova CLI: 6.4.0
Ionic Framework Version: 2.0.0-rc.3
Ionic CLI Version: 2.1.12
Ionic App Lib Version: 2.1.7
Ionic App Scripts Version: 0.0.45
ios-deploy version: Not installed
ios-sim version: 5.0.8
OS: macOS Sierra
Node Version: v7.2.0
Xcode version: Xcode 8.1 Build version 8B62
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 1
- Comments: 15 (14 by maintainers)
Commits related to this issue
- fix(tabs): current tab still active if selected tab does not have a root The current selected tab should NOT be deselected (i.e. detached from change detection) if the selected tab does not have a ro... — committed to manucorporat/ionic by manucorporat 8 years ago
- fix(tabs): current tab still active if selected tab does not have a root The current selected tab should NOT be deselected (i.e. detached from change detection) if the selected tab does not have a ro... — committed to ionic-team/ionic-framework by manucorporat 8 years ago
Legend.
@kelvindart yes! I can reproduce it, looking into it! Thanks again for the plunker!