Ionic-framework: V2 - Beta 5 - Alert in Modal break Tabs navigation

Created on 21 Apr 2016  路  2Comments  路  Source: ionic-team/ionic-framework

Short description of the problem:

If on a tab page, you're opening a modal, which opens an alert which closes the modal, then the tabs navigation doesn't work anymore

Steps to reproduce:

  1. Open this plunkr http://plnkr.co/edit/SJ8GtqbRntby5yGzLEft?p=preview
  2. Click on the button open modal
  3. Click on the button close me
  4. Click on yes
  5. Try to navigate to the other Tab, you can't anymore

lunker20160421210937

Which Ionic Version? 2.x

Most helpful comment

@JumBay In this case it's best to manually dismiss the alert, wait for the alert to finish animating out, then dismiss the modal, like this:

closeMe() {
  let confirm = Alert.create({
    title: 'Close Me?',
    buttons: [
      {
        text: 'Yes',
        handler: () => {
          confirm.dismiss().then(() => {
            this.viewCtrl.dismiss();
          });
          return false;
        }
      },
      {
        text: 'No'
      }
    ]
  });

  this.nav.present(confirm);
}

Note that the handler now returns false so that it doesn't automatically dismiss the alert.

We just recently documented this under the "Dismissing And Async Navigation" section:
http://ionicframework.com/docs/v2/api/components/alert/Alert/

And in the "Nav Transition Promises" section:
http://ionicframework.com/docs/v2/api/components/nav/NavController/

Hope that helps!

All 2 comments

@JumBay In this case it's best to manually dismiss the alert, wait for the alert to finish animating out, then dismiss the modal, like this:

closeMe() {
  let confirm = Alert.create({
    title: 'Close Me?',
    buttons: [
      {
        text: 'Yes',
        handler: () => {
          confirm.dismiss().then(() => {
            this.viewCtrl.dismiss();
          });
          return false;
        }
      },
      {
        text: 'No'
      }
    ]
  });

  this.nav.present(confirm);
}

Note that the handler now returns false so that it doesn't automatically dismiss the alert.

We just recently documented this under the "Dismissing And Async Navigation" section:
http://ionicframework.com/docs/v2/api/components/alert/Alert/

And in the "Nav Transition Promises" section:
http://ionicframework.com/docs/v2/api/components/nav/NavController/

Hope that helps!

Oh I didn't that.
That's exactly what I needed.
Thanks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

BilelKrichen picture BilelKrichen  路  3Comments

manucorporat picture manucorporat  路  3Comments

alexbainbridge picture alexbainbridge  路  3Comments

SebastianGiro picture SebastianGiro  路  3Comments

Macstyg picture Macstyg  路  3Comments