ionic-team / ionic-team/ionic-framework
bug: adding buttons to alert with the same role causes the first handler to always be fired
- Vorherrschende Sprache
- TypeScript
- Sterne
- 52.7k
- Forks
- 13.3k
- Ø Merge
- 1 T. 15 Std.
- Gemergte PRs (30 T.)
- 51
Beschreibung
# Bug Report
**Ionic version:**
[ ] **4.x**
[x] **5.x**
**Current behavior:**
If two buttons in an alert both have the `cancel` role, only the first handler will ever be called, regardless of which button is pressed. Changing the roles to be different will result in expected behavior.
**Expected behavior:**
The handler for the pressed button should be called, regardless of its 'role'.
**Steps to reproduce:**
1. See code below.
2. Click "BUTTON 2"
3. Observe that the handler for "BUTTON 1" will have been called.
**Related code:**
```
const alert = await this.alertCtrl.create({
header: 'Header',
message:'Some message here',
buttons:[{
text: 'BUTTON 1',
role: 'cancel',
handler: () => {
console.log('BUTTON 1');
}
}, {
text: 'BUTTON 2',
role: 'cancel',
handler: () => {
console.log('BUTTON 2');
}
}]
});
alert.present();
```
Aside... can we get an updated StackBlitz/Plunkr for the latest version of Ionic Angular, etc? :) They are still on 3 & 4.
**Other information:**
**Ionic info:**
```
sharktop:topdecked-unified lincoln$ ionic info
Ionic:
Ionic CLI : 6.12.4 (/usr/local/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/angular 5.6.0
@angular-devkit/build-angular : 0.1200.0-next.3
@angular-devkit/schematics : 12.0.0-next.3
@angular/cli : 12.0.0-next.3
@ionic/angular-toolkit : 3.1.0
Capacitor:
Capacitor CLI : 3.0.0-beta.6
@capacitor/core : 3.0.0-beta.6
Utility:
cordova-res : 0.15.3
native-run : 1.3.0
System:
NodeJS : v14.15.0 (/usr/local/bin/node)
npm : 6.14.9
OS : macOS Catalina
```
Beitragsleitfaden
Bewertung
Dieses Issue wurde noch nicht bewertet.