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.

bug: passing max only causes ion-datetime is out of bounds

See original GitHub issue

Prerequisites

Ionic Framework Version

  • v4.x
  • v5.x
  • v6.x
  • Nightly

Current Behavior

I have a field to select the date of birth. The rule is to start showing dates 10 years before today. In the meanwhile, the field should be empty until you select a date.

example image

When setting the max to 2012-08-26T12:47:01.977Z or to 2012, I receive this warning:

The value provided to ion-datetime is out of bounds.

Min: undefined
Max: {"month":8,"day":26,"year":2012,"hour":12,"minute":47}
Value: {"year":2022,"month":8,"day":26,"hour":8,"minute":56,"tzOffset":0}

I understand the warning and I see that the Value (2022) is greater than the Max (2012). It seems that the component is picking up the today Date automatically.

Trying to set the field’s value with the same max date that I have provided, the warning disappears.

example image

This can be confusing because the reality is that the user did not select a date yet. Also, when the user see that date, he can think that was automatically pulled from its account settings, which is false.

Expected Behavior

  • The component should not take today date automatically.
  • If no Value exists, should render the dates taken into account min/max settings.

Steps to Reproduce

<ion-modal trigger="open-modal">
  <ng-template>
    <ion-content>
      <ion-datetime
        #datetime
        size="cover"
        [(ngModel)]="value"
        max="2012-08-26T12:47:01.977Z"
        [preferWheel]="true"
      ></ion-datetime>
    </ion-content>
  </ng-template>
</ion-modal>

Code Reproduction URL

No response

Ionic Info

Ionic:

   Ionic CLI                     : 6.20.1
   Ionic Framework               : @ionic/angular 6.2.4
   @angular-devkit/build-angular : 14.1.1
   @angular-devkit/schematics    : 14.1.1
   @angular/cli                  : 14.1.1
   @ionic/angular-toolkit        : 7.0.0

Capacitor:

   Capacitor CLI      : 3.6.0
   @capacitor/android : 3.6.0
   @capacitor/core    : 3.6.0
   @capacitor/ios     : 3.6.0

Utility:

   cordova-res : 0.15.4
   native-run  : 1.6.0

System:

   NodeJS : v16.16.0
   npm    : 8.18.0
   OS     : macOS Monterey

Additional Information

Maybe this behavior was intended and decided for some reason, but if this is the case, how can I accomplish a simple UX like the one I have described before?

My goal is to let the user select a date in the past while keeping the field/component with no initial value.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
RRGT19commented, Aug 26, 2022

Thanks for your response.

I confirm with that dev build that now is working as intended, no matter the datetime format you use.

Thanks a lot!.

0reactions
ionitron-bot[bot]commented, Sep 29, 2022

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

ion-datetime - Ionic Framework
Datetimes present a picker interface to select dates and times. Ionic's API Datetime input component easily displays a preferred format, and manages values....
Read more >
ion-datetime dynamic value change doesn't work for certain ...
Okay, I finally found the problem. I initially used the Date.toISOString() method and splitted the result to get just the date, ...
Read more >
MySQL 5.7 Reference Manual :: 12.7 Date and Time Functions
Several functions are strict when passed a DATE() function value as their argument and reject incomplete dates with a day part of zero:...
Read more >
ArgumentOutOfRangeException Class (System)
The exception that is thrown when the value of an argument is outside the allowable range of values as defined by the invoked...
Read more >
What's new in 1.1.0 (July 28, 2020) - Pandas
Now the error message also includes a list of the missing labels (max 10 items, ... Previously, declaring or converting to StringDtype was...
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