question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[4.12.0] [ion-picker] dismiss function doesn't pass data and role data to onDidDismiss

See original GitHub issue

Bug Report

Ionic version:

4.12.0

Current behavior: When the ion-picker gets dismissed the onDidDismiss() data and role properties are both undefined.

Expected behavior: When the picker gets dismissed it should have the role parameter set. E.g. When closing via a Button with that button’s role. So we can perform some action based on whether the user clicked the button or not

Steps to reproduce: Create a picker, present it and tap on one of the buttons so the onDidDismiss() method is called.

const picker = await this.pickerController.create({
  buttons: [
   {
     text: 'CANCEL',
     role: 'cancel'
   },
   {
     text: 'CONFIRM',
     role: 'confirm'
   }
  ],
  columns: [
    {
      name: 'column',
      options: [
        {
          text: 'First',
          value: 'first'
        },
        {
          text: 'Second',
          value: 'second'
        }
      ]
    }
  ]
});

picker.present();

const dismiss = await picker.onDidDismiss();
console.log('Dismissed picker', dismiss);
if(dismiss.role === 'close') {
  console.log('Close button pressed!');
}

Ionic info:

Ionic:

   ionic (Ionic CLI)             : 4.12.0
   Ionic Framework               : @ionic/angular 4.2.0
   @angular-devkit/build-angular : 0.13.6
   @angular-devkit/schematics    : 7.2.4
   @angular/cli                  : 7.2.4
   @ionic/angular-toolkit        : 1.4.0

Cordova:

   cordova (Cordova CLI) : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms     : not available
   Cordova Plugins       : not available

System:

   NodeJS : v10.16.0 (/home/dletran/.nvm/versions/node/v10.16.0/bin/node)
   npm    : 6.9.0
   OS     : Linux 4.13

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
brandyscarneycommented, Oct 29, 2019

PR submitted here: https://github.com/ionic-team/ionic/pull/19787

Dev release is based on the 5.0.0-beta.0 release: 5.0.0-dev.201910292106.aebfdfc

1reaction
hidertanurecommented, Sep 23, 2019

Hi guys, As a workaround, my issue was solved using the handler callback like this:

{ text: 'Done', role: 'select', handler: (value) => { console.log(value); } }

Don’t need to use the onDidDismiss anymore.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[4.12.0] [ion-picker] dismiss function doesn't pass data and ...
When the ion-picker gets dismissed the onDidDismiss() data and role properties are both undefined. Expected behavior: When the picker gets ...
Read more >
Ionic Modal not passing data back - Stack Overflow
I don't think using a setTimeout can cause this issue. Let's find it out, try the following code which is working on my...
Read more >
Display Buttons and Columns for ion-picker on Ionic Apps
A Picker is a dialog that displays a row of buttons and columns underneath. Ion-picker appears on top of the app's content, and...
Read more >
ionic/docs/core.json - UNPKG
Additionally, if the action sheet is dismissed by tapping the backdrop, then it will fire the handler from the button with the cancel...
Read more >
Ionic modals passing and receiving data - Daily Dev Tips
That is how easy it is to pass data to our modal component. Ionic modal dismiss receive data permalink. Of course, we also...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found