Ionic-framework: Ionic 2: Confirm button with role:cancel does not fire on android back button

Created on 22 Aug 2016  路  11Comments  路  Source: ionic-team/ionic-framework

Short description of the problem:

When presenting an alert since beta 11, if the user presses the Android hardware back button, the role: 'cancel' handler is not fired.

In previous beta versions, this was fired.

What behavior are you expecting?

For the Android back button to fire the handler with role: 'cancel'

Steps to reproduce:

  1. Put the code below on a page linked to a button
  2. Notice that when pressing hardware back button, alert is not fired.
let confirm = this._alertController.create({
        title: 'Do You agree?',
        message: 'Please say whether you agree',
        buttons: [
          {
            role: 'cancel',
            text: 'Disagree',
            handler: () => {
              alert('cancelled')
            }
          },
          {
            text: 'Agree',
            handler: () => {
            }
          }
        ]
});
confirm.present();

Other information: (e.g. stacktraces, related issues, suggestions how to fix, stackoverflow links, forum links, etc)

Which Ionic Version? 1.x or 2.x
2.x

Plunker that shows an example of your issue

Sorry, but I can't show this in a plunkr as it requires the android hardware button.

Run ionic info from terminal/cmd prompt: (paste output below)
Davids-Air:AppHazard daveshirman$ ionic info

Your system information:

Cordova CLI: 6.2.0
Ionic Framework Version: 2.0.0-beta.11
Ionic CLI Version: 2.0.0-beta.32
Ionic App Lib Version: 2.0.0-beta.18
ios-deploy version: 1.8.6
ios-sim version: 5.0.8
OS: Mac OS X El Capitan
Node Version: v4.3.0
Xcode version: Xcode 7.2.1 Build version 7C1002

v3

Most helpful comment

Hello, can someone from the Ionic team please reply to this? @jgw96

All 11 comments

Hi, any news on this? Anyone?? @jgw96

Hello, can someone from the Ionic team please reply to this? @jgw96

Hello, thanks for opening an issue with us! I am very sorry for the delay on this one, we have been very focused with getting the RC.0 release out. We will be looking at adding this enhancement.

@daveshirman we are aware of this issue, and I have disabled hardware go back support for Alerts/Actionsheet, since this bug can lead to deadlocks. For example, if the alert needs to resolve a promise, the cancel handler is never called, and the promise is never resolved.

Hardware Go back support has been improved a lot, now it works with modals, tabs, and nested navigation stacks.

Support for Alerts is pending though

@manucorporat Hey, is this really a good solution though? All Android apps use allow the hardware/software back button to dismiss alerts and actionsheets. Isn't this just breaking user expectation and therefore the illusion of a native app?

@daveshirman it is not a solution, but it is better to disable a buggy feature that can lead to worst scenarios (like a frozen app).

The fix for this issue is not trivial and we are about to release a new version very soon, it is too later for big changes.

From a UX, you are right. But a Alert is a UI element that is asking for user interaction, an alert WANTS the user to do something, so we think disabling the hardware go back is not a big deal from an UX point of view in the meantime.

@manucorporat Yep, totally agree. Look forward to the next release, especially navigation fixes (setRoot etc).

Thanks for all your team's hard work. Loving working with this framework.

Hello ! Any idea when this will be implemented ?

Is this Issue solved or still open?

This issue has been automatically identified as an Ionic 3 issue. We recently moved Ionic 3 to its own repository. I am moving this issue to the repository for Ionic 3. Please track this issue over there.

If I've made a mistake, and if this issue is still relevant to Ionic 4, please let the Ionic Framework team know!

Thank you for using Ionic!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vswarte picture vswarte  路  3Comments

MrBokeh picture MrBokeh  路  3Comments

masimplo picture masimplo  路  3Comments

BilelKrichen picture BilelKrichen  路  3Comments

giammaleoni picture giammaleoni  路  3Comments