ionic-team / ionic-team/ionic-framework

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

Đang mở
#23,037 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
package: core type: bug
Ngôn ngữ chính
TypeScript
Star
52.7k
Fork
13.3k
Merge trung bình
1 ngày 15 giờ
Pull request đã merge (30 ngày)
51

Mô tả

# 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

```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.