ionic-team / ionic-team/ionic-framework

bug: adding buttons to alert with the same role causes the first handler to always be fired

オープン
#23,037 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
package: core type: bug
主要言語
TypeScript
スター
52.7k
フォーク
13.3k
平均マージ
1日 15時間
マージ済み PR(30日)
51

説明

# 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

```

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。