Alert doesn't dismiss if triggered from an action sheet

Hello,
I’m migrating an App from Ionic 2 (rc5) to ionic 3.
On one of the pages, I have an alert (prompt) that is triggered by clicking an actionSheet item

presentActionSheet() {
	let actionSheet = this.actionSheetCtrl.create({
      title: 'Edit',
      buttons: [
        {
          text: 'Rename',
          handler: () => {
            this.showRename();
          }
        }
      ]
    });
    actionSheet.present();
}

showRename() {
	let prompt = this.alertCtrl.create({
	  title: 'Rename',
	  message: "Enter a name",
	  inputs: [
		{
		  name: 'Name',
		  placeholder: ''
		},
	  ],
	  buttons: [
		{
		  text: 'Cancel',
		  handler: data => {
			console.log('Cancel clicked');
		  }
		},
		{
		  text: 'Save',
		  handler: data => {
			  console.log('Saved clicked');
		  }
		}
	  ]
	});
	prompt.present();
}

The problem is that none of the button is working: the console.log are there when I click but the alert simply doesn’t close.

If I put the showRename() function in the constructor to show the alert directly when the page load or on a button click for example, the behavior is correct (button clicked = closing the alert).

This was working fine with the previous version of Ionic I used, it’s the last and only problem I encountered while migrating (for the moment ^^).

Does someone have an idea of why it happens ?

global packages:

    @ionic/cli-utils : 1.4.0
    Ionic CLI        : 3.4.0

local packages:

    @ionic/app-scripts              : 1.3.12
    @ionic/cli-plugin-ionic-angular : 1.3.1
    Ionic Framework                 : ionic-angular 3.5.0

System:

    Node       : v6.9.4
    OS         : Windows 10
    Xcode      : not installed
    ios-deploy : not installed
    ios-sim    : not installed
    npm        : 3.10.10

Thanks,

1 Like

Same issue - worked in 3.4 but not in 3.5. I tried wrapping the alertCtrl.create() in a Promise and in the cancel I did:

          {
            text: 'Cancel',
            role: 'cancel',
            handler: () => {
              prompt.dismiss().then(() => reject())
            }
          }

The alert doesn’t come down…

Ah it’s been reported as a bug: https://github.com/ionic-team/ionic/issues/12225

1 Like

Good that there is a bug opened :slight_smile:
I tried a lot of things too and found a quick dirty fix: the idea is to timeout the opening of the alert:

presentActionSheet() {
	let actionSheet = this.actionSheetCtrl.create({
      title: 'Edit',
      buttons: [
        {
          text: 'Rename',
          handler: () => {
           setTimeout(() => {
             this.showRename();
           }, 400)
          }
        }
      ]
    });
    actionSheet.present();
}

I’ll post it on the bug report hoping it will help to fix the issue properly ^^

Did you find any issue when the alerts shows up? The actionSheet closes without any animation