bug: ion-datetime custom button with role="cancel" still updates value
See original GitHub issueBug 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
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:19 (8 by maintainers)
Top Results From Across the Web
ion-datetime - Ionic Framework
This component displays buttons which show the current date and time values. When the buttons are tapped, the date or time pickers open...
Read more >How to use the Ionic 6 Datetime component - YouTube
In this video we are taking a closer look at the Ionic 6 datetime component and implement a stylish modal that works for...
Read more >Ionic 6 ion-datetime | Complete guide - YouTube
Hello Friends, Welcome Back to @CodingTechnyks. In this video, we are going to work with Ionic 6 ion-datetime using #ionic #angular for ...
Read more >@ionic/core | Yarn - Package Manager
Ionic is an open source app development toolkit for building modern, fast, top-quality cross-platform native and Progressive Web Apps from a single codebase ......
Read more >Ionic v4 datepicker clear button? - angular - Stack Overflow
Based on what I'm reading I would be tempted to open a bug on Ionic to say that the feature is essentially unusable....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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