Ionic-framework: Ionic (Angular) alert handler method called twice

Created on 24 Jun 2020  路  3Comments  路  Source: ionic-team/ionic-framework

Bug Report

Ionic version:
[x] 5.x

Current behavior:
When using Ionic Alert controller, "ok button" handler method is called twice. When I add role: "cancel" to the ok button, it is called only once like it should.

Related code:

async showDialog(iterable: Array<any>) {
    let inputs: Array<any> = [];

    for (const x of iterable) {
      inputs.unshift({
        name: x.title,
        type: "radio",
        label: x.title,
        value: x,
        handler: (value) => {
          this.someOtherMethod(value.value);
          alert.dismiss();
        },
      });
    }

    const alert = await this.alertController.create({
      header: "Title",
      message: "Message",
      inputs: inputs,
      buttons: [
        {
          text: "Cancel",
          role: "cancel",
          cssClass: "cancel-t-button",
          handler: () => {},
        },
        {
          text: "Add",
          role: "ok",
          cssClass: "add-t-button",
          handler: () => this.someMethod(),
        },
      ],
    });

    await alert.present();
  }
triage

Most helpful comment

Thanks for the issue. Update to Ionic Framework v5.2.2. This issue was fixed in that release.

All 3 comments

Thanks for the issue. Update to Ionic Framework v5.2.2. This issue was fixed in that release.

Thanks for the issue. Update to Ionic Framework v5.2.2. This issue was fixed in that release.

Thanks, it's working now.

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

BilelKrichen picture BilelKrichen  路  3Comments

alexbainbridge picture alexbainbridge  路  3Comments

fdnhkj picture fdnhkj  路  3Comments

GeorgeAnanthSoosai picture GeorgeAnanthSoosai  路  3Comments

masimplo picture masimplo  路  3Comments