Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
lincolnthree opened this issue Mar 11, 2021 · 0 comments
Labels
package: core @ionic/core package type: bug a confirmed bug report

Comments

@lincolnthree
Copy link

lincolnthree commented Mar 11, 2021

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

@ionitron-bot ionitron-bot bot added the triage label Mar 11, 2021
@liamdebeasi liamdebeasi changed the title bug: Duplicate Alert button handler 'role' values cause incorrect handlers to be executed bug: adding buttons to alert with the same role causes the first handler to always be fired Mar 16, 2021
@liamdebeasi liamdebeasi added package: core @ionic/core package type: bug a confirmed bug report labels Mar 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: core @ionic/core package type: bug a confirmed bug report
Projects
None yet
2 participants