Min and max properties of ion-datetime are not working properly
See original GitHub issueBug Report
Ionic version: [x] 4.0.0-rc.1
Current behavior: The selected date on the datetime picker does not update while choosing a date, this has a few issues with the min and max properties:
min property
If I set the the min
property to today’s date, the datetime picker does not show the past days from the current month as expected. But when scrolling to the next month, the previous days are still not available in the picker. To select a day that is lower than the current day, you need to first select the next month, tap “Done” and then open the picker again and select the desired day.
E.g.:
<ion-datetime
displayFormat="DD/MMM"
min="2019-01-11">
</ion-datetime>
If I want to select 2nd of February, I need first to select February, then re-open the picker and select the day.
max property
A similar issue happens with the max property. If you set the max
property to any month in the future, you can first scroll to a day that is after the max day, and then scroll to the month from the max
property. This will allow you to select a date that is after the max
property. When using (ionChange)
to view these values, you can check that the emitted value is actually after the max
property.
Expected behavior:
When using the datetime picker, I expect to be able to select any value between the min
and max
properties, without having to close and open the picker again to update the available options.
Steps to reproduce:
For min
bug:
Use the code below and scroll down to Feb
. Days between 1 and 11 are to available unless you click done
and open again.
<ion-datetime
displayFormat="DD/MMM"
min="2019-01-11">
</ion-datetime>
For max
bug:
Use the code below and scroll down to day 30
. Scroll down to May and you will be able to select a date after 2019-05-11
.
<ion-datetime
displayFormat="DD/MMM"
max="2019-05-11">
</ion-datetime>
Related code: Please, update the plunker links to provide a Ionic 4 same app 👍
Other information:
Ionic info:
Ionic:
ionic (Ionic CLI) : 4.5.0 (/usr/local/lib/node_modules/ionic)
Ionic Framework : @ionic/angular 4.0.0-rc.1
@angular-devkit/build-angular : 0.10.7
@angular-devkit/schematics : 7.1.4
@angular/cli : 7.0.7
@ionic/angular-toolkit : not installed
Cordova:
cordova (Cordova CLI) : 7.1.0
Cordova Platforms : android 6.4.0
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 2.3.1, (and 5 other plugins)
System:
Android SDK Tools : 26.1.1 (/Users/~username~/Library/Android/sdk/)
ios-deploy : 1.9.2
NodeJS : v8.12.0 (/usr/local/bin/node)
npm : 6.4.1
OS : macOS Mojave
Xcode : Xcode 9.2 Build version 9C40b
Disclaimer: English is not my native language so the issue description might be a bit confusing. Please let me know if you need a clearer example in order to reproduce this issue.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:6 (2 by maintainers)
Top GitHub Comments
ion datetime has a lot of issues, see collected here -> #16630
I added yours to the list because you made some easy understandable codes to reproduce 😃
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.