Ionic 2: Confirm button with role:cancel does not fire on android back button
See original GitHub issueShort 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:
- Put the code below on a page linked to a button
- 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
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:11 (3 by maintainers)
Hello, can someone from the Ionic team please reply to this? @jgw96
@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.