Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: datetime, setting value out of bounds prevents user from navigating in bounds #24881

Closed
4 of 6 tasks
Yura13 opened this issue Mar 4, 2022 · 5 comments
Closed
4 of 6 tasks
Labels
package: core @ionic/core package type: bug a confirmed bug report

Comments

@Yura13
Copy link

Yura13 commented Mar 4, 2022

Prerequisites

Ionic Framework Version

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

Current Behavior

datepicker-min-max-attributes

Expected Behavior

I should have a possibility to navigate to the available months.

Steps to Reproduce

I am trying to edit the saved date but can't navigate to the next month.
Saved date is 2021-12-12
Min date is 2022-03-04
Max date is 2022-04-03

Code Reproduction URL

No response

Ionic Info

Ionic:

Ionic CLI : 6.18.1 (C:\Users\Xiaomi\AppData\Roaming\nvm\v16.13.2\node_modules@ionic\cli)
Ionic Framework : @ionic/angular 6.0.10
@angular-devkit/build-angular : 13.1.3
@angular-devkit/schematics : 13.1.3
@angular/cli : 13.1.3
@ionic/angular-toolkit : 5.0.3

Cordova:

Cordova CLI : 10.0.0 ([email protected])
Cordova Platforms : android 9.1.0, browser 6.0.0
Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 5.0.0, cordova-plugin-ionic 5.5.1, (and 28 other plugins)

Utility:

cordova-res : not installed globally
native-run : 1.5.0

System:

Android SDK Tools : 26.1.1 (C:\Android\android-sdk)
NodeJS : v16.13.2 (C:\Program Files\nodejs\node.exe)
npm : 8.1.2
OS : Windows 10

Additional Information

No response

@ionitron-bot ionitron-bot bot added the triage label Mar 4, 2022
@liamdebeasi
Copy link
Contributor

Thanks for the issue. The current expectation is that developers must provide a valid date to the value property. Given the max and min values you provided, 2021-12-12 is not a valid value as it is out of bounds.

However, we can look into improving this developer experience so I will add this to our tracker.

@liamdebeasi liamdebeasi changed the title Datepicker can't navigate to available months based on min and max attributes bug: datetime, setting value that is out of bounds leads to a confusing user experience Mar 4, 2022
@liamdebeasi liamdebeasi added package: core @ionic/core package type: bug a confirmed bug report labels Mar 4, 2022
@ionitron-bot ionitron-bot bot removed the triage label Mar 4, 2022
@philkonick
Copy link

philkonick commented Mar 15, 2022

This is still related to the bug where you can't navigate to a month that contains a min or max date, if the day of that date is greater or less than the current day respectively. Please see here for the explanation based on my testing.

For usability, I do also think the user should be able to navigate to any month between the current date and the month containing the min date. A simple workaround for this would be to set value=min on initialisation, which would immediately put the selected date into the valid date range, however the other bug I mentioned above will still prevent this workaround from working correctly.

Found a more recent open bug that deals with this problem more specifically, linking here.

@liamdebeasi
Copy link
Contributor

The team met to discuss this behavior. Here is out current plan for addressing this:

When no value is set:

  • The datetime will render the calendar on an in-bound month and will never start the user out of bounds.
  • It will use the following algorithm to determine which month to render:
  1. If the minimum month > today’s month, show the minimum month.
  2. If the maximum month < today’s month, show the maximum month.
  3. Otherwise, show today’s month.
  • The time picker will show all possible values until you select a date at which point it will only show the times that are in bounds according to the date you selected.

When a value Is set:

  • The datetime will add a console.warn informing the developer that the current value is out of bounds.
  • The datetime will render the calendar on a current in-bound month. It will use the above algorithm to determine which month to render.

In neither case will the datetime modify the value set.

@liamdebeasi liamdebeasi changed the title bug: datetime, setting value that is out of bounds leads to a confusing user experience bug: datetime, setting value out of bounds prevents user from navigating in bounds May 23, 2022
@averyjohnston
Copy link
Contributor

This has been resolved via #25351 and #25513. The former, which accounts for most of the fix, has already been released in Ionic 6.1.9. The latter, which adds console warnings for better DX, will be available in a future release of Ionic 👍

@ionitron-bot
Copy link

ionitron-bot bot commented Jul 22, 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.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Jul 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
package: core @ionic/core package type: bug a confirmed bug report
Projects
None yet
Development

No branches or pull requests

4 participants