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

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

Closed
dletran opened this issue Jun 4, 2019 · 12 comments · Fixed by #19787
Closed
Labels
package: core @ionic/core package type: bug a confirmed bug report

Comments

@dletran
Copy link

dletran commented Jun 4, 2019

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
@ionitron-bot ionitron-bot bot added the triage label Jun 4, 2019
@brandyscarney
Copy link
Member

brandyscarney commented Jun 4, 2019

@brandyscarney brandyscarney added package: core @ionic/core package type: bug a confirmed bug report labels Jun 4, 2019
@ionitron-bot ionitron-bot bot removed the triage label Jun 4, 2019
@lukabers
Copy link

Any updates on this issue?

@jeffricks
Copy link

Also interested in a fix for this. Cancelling a picker is a pretty fundamental operation for a core component.

@abalad
Copy link

abalad commented Aug 22, 2019

Same issue here

@hartherbert
Copy link

Any updates ? Having the same issue.

@RashmiChandran
Copy link

Hi Team, Any updates for this issue?

@hidertanure
Copy link

hidertanure commented 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.

@BrunoUY
Copy link

BrunoUY commented Oct 10, 2019

Hi, Any news?

@LucaCorcella
Copy link

Hi, any news?

picker.onDidDismiss().then(data => { console.log(data); });.

return undefiined

@brandyscarney
Copy link
Member

PR submitted here: #19787

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

brandyscarney added a commit that referenced this issue Oct 30, 2019
…or backdrop (#19787)

- Pass the button role on dismiss of the picker (on button click or backdrop tap)
- Pass the selected values in the data on dismiss ONLY if the dismiss role is not "cancel" or "backdrop"
- Call the cancel handler when dismissing if the role is "cancel" or "backdrop"

Fixes #18454
elylucas pushed a commit that referenced this issue Oct 30, 2019
…or backdrop (#19787)

- Pass the button role on dismiss of the picker (on button click or backdrop tap)
- Pass the selected values in the data on dismiss ONLY if the dismiss role is not "cancel" or "backdrop"
- Call the cancel handler when dismissing if the role is "cancel" or "backdrop"

Fixes #18454
mhartington pushed a commit that referenced this issue Oct 31, 2019
…or backdrop (#19787)

- Pass the button role on dismiss of the picker (on button click or backdrop tap)
- Pass the selected values in the data on dismiss ONLY if the dismiss role is not "cancel" or "backdrop"
- Call the cancel handler when dismissing if the role is "cancel" or "backdrop"

Fixes #18454
@claytongulick
Copy link

fix won't be backported to 4.x branch?

@ionitron-bot
Copy link

ionitron-bot bot commented Dec 19, 2019

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.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Dec 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
package: core @ionic/core package type: bug a confirmed bug report
Projects
None yet