question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Min and max properties of ion-datetime are not working properly

See original GitHub issue

Bug 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:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
paulstelzercommented, Jan 11, 2019

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 😃

0reactions
ionitron-bot[bot]commented, Mar 14, 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Struggling to get ion-datetime min & max working correctly
Hi,. I'm struggling to get the ion-datetime component working correctly. My issue is with setting the min and max values.
Read more >
Setting min/max on ion-datetime component does not work ...
I am using ion-datetime and I have set min and max property for restrict time selection. <ion-datetime display-format="hh:mm A" ...
Read more >
The New Datetime Component In Ionic - Ionic Blog
Get the backstory on the changes to the new Ionic Datetime component and how you can upgrade to use the new verion today....
Read more >
Angular and Ionic Date & Time Min & max values Example
Configuring minimum and maximum selectable values is great for reducing mistakes. Help people by limiting the selections for the task at hand.
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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found