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:

  1. Clone the following repository: https://github.com/kelvindart/ionic2-tabs-lifecycle.
  2. mkdir www so Ionic/Cordova recognises it as a Cordova project.
  3. Run npm install.
  4. Run ionic serve.
  5. Tap “Go to Tabs”.
  6. Tap “Log out”.
  7. Tap “No”.
  8. 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

Most upvoted comments

Legend.

@kelvindart yes! I can reproduce it, looking into it! Thanks again for the plunker!