ionic-framework: bug: ion-datetime custom button with role="cancel" still updates value
Bug Report
Ionic version: [x] 4.x
Current behavior:
I use the pickerOptions property of the ion-datetime to add buttons with custom handlers. I add a “Cancel” button with role: 'cancel'. When I click that cancel button, the value of the ion-datetime changes anyway.
Expected behavior:
A picker button with role cancel should not change the ion-datetime’s value.
Steps to reproduce:
<ion-datetime display-format="YYYY" value="2019" />
document.querySelector('ion-datetime').pickerOptions = {
buttons: [
{ text: 'Cancel', role: 'cancel' },
{ text: 'Done', handler: columns => console.log(columns.year.value) },
],
};
Related code:
https://codepen.io/simonhaenisch/pen/YzPwYZa?editors=1010
Other information:
I think #19441 is about the same issue but not sure.
This is the code that looks like it should be working:
Ionic info:
@ionic/core: 4.11.5
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 5
- Comments: 19 (8 by maintainers)
Do you have any updates on this?
As a quick fix I added an @ngIf on the component and I am reinitializing the compnent in the cancel handler.
this is still true with ionic/react 5.5.0
Any Updates on this? Its still persist on Ionic 5.0.4.
@brandyscarney Can you provide an example? I tried setting the handler but it didn’t work and still, the value gets changed by clicking cancel as well as clicking on the backdrop
Also, why we don’t get the default buttons like in
"ionic-angular": "3.5.2"adding the select and cancel buttons is so problematic !!!I’m currently on
"@ionic/angular": "^4.7.1"