You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched for existing issues that already include this feature request, without success.
Describe the Feature Request
I propose adding an option to the ion-datetime component that allows it to emit the ionChange event only when the user selects a day. This would make the component more practical for range selection, as it would only emit events when the user has made a complete date selection.
Describe the Use Case
It opens up the possibility to use this datetime picker for selection of a date range with the multiple attribute.
Instead of,
Currently, the ion-datetime component emits the ionChange event whenever the user changes the year, month, or day. This make it almost impossible when using the component for range selection, as it triggers unnecessary events when changing the year or month regardless whether or not, client actually want that value to be register.
Describe Preferred Solution
So inside the ion-datetime element, add a property that based on 3 types of string, day/month/year (I suggest day would be the most heavy use case so it could be a boolean as well).
Then maybe in ionic library, in the logic that will automatically emits a new value, when changing year or month. Use an if case to read this value, then early return to quit the logic that automatically emits a new value.
Describe Alternatives
An alternative solution could be to implement custom logic to revert the value when the user changes the year or month and only allow the ionChange event to be emitted when the user selects a day.
Yet this approach caused bug and confusion when user actually select the date range with the same day but different year as this legit action from user will be catergorized as ionic automatic emits instead in this alternative approach.
Hence this approach may be more complex and less intuitive for developers.
Thanks for the report. The use case provided is for date range selection, so I am going to merge this with #23572. I think it would be best to implement proper date range selection so developers do not need to implement it themselves.
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.
Prerequisites
Describe the Feature Request
I propose adding an option to the ion-datetime component that allows it to emit the ionChange event only when the user selects a day. This would make the component more practical for range selection, as it would only emit events when the user has made a complete date selection.
Describe the Use Case
It opens up the possibility to use this datetime picker for selection of a date range with the multiple attribute.
Instead of,
Currently, the ion-datetime component emits the ionChange event whenever the user changes the year, month, or day. This make it almost impossible when using the component for range selection, as it triggers unnecessary events when changing the year or month regardless whether or not, client actually want that value to be register.
Describe Preferred Solution
So inside the ion-datetime element, add a property that based on 3 types of string, day/month/year (I suggest day would be the most heavy use case so it could be a boolean as well).
Then maybe in ionic library, in the logic that will automatically emits a new value, when changing year or month. Use an if case to read this value, then early return to quit the logic that automatically emits a new value.
Describe Alternatives
An alternative solution could be to implement custom logic to revert the value when the user changes the year or month and only allow the ionChange event to be emitted when the user selects a day.
Yet this approach caused bug and confusion when user actually select the date range with the same day but different year as this legit action from user will be catergorized as ionic automatic emits instead in this alternative approach.
Hence this approach may be more complex and less intuitive for developers.
Related Code
<ion-datetime [onChange-only]="day" [multiple="true"]></ion-datetime>
Additional Information
No response
The text was updated successfully, but these errors were encountered: