-
Notifications
You must be signed in to change notification settings - Fork 15
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
Date Picker Default Initial Month #450
Comments
We've found that the calendar is behaving as intended, but agree that this can be confusing so it can be improved. The issue isn't actually related to min and max dates that span years. It's caused by the calendar attempting to open on a month with enabled dates — if the min date occurs after the current month it goes to the earliest enabled month, and if the max date occurs before the current month it goes to the latest enabled month. Basically the calendar by default takes you to the closest enabled dates. The behavior probably stood out more or seemed especially wrong now because it's close to the beginning of the year. So we came up with three possible solutions:
Of those the second option seemed to make the most sense for now. The calendar will open on the current date if possible, but if all the enabled dates are in the past it will open on the earliest of those. Here's the PR that implements it — #472 Does that seem like an acceptable solution? |
Thanks for the update! I'm not sure I'm understanding the explanation, so I'm going to use examples. I'm referencing the datepicker on the forge dev documentation for this. When I set the min date to 01/03/2024 and max to 03/26/2024, the calendar opens to the current month (February), which is what I would expect. Will this change fix the second example, as I would expect it to open to February in either situation? You mention specifically having both the min/max dates in the past, so I just want to clarify. Thanks! |
You're absolutely right. Somehow the dates I tested with never ran into this problem, but there are some combinations where the calendar wrongly thinks that the current date is outside the min and max. I updated the PR to fix that. Specifically, it would test the month and year separately and determine that the date was under/over the min/max if either the month or year was. Changing that to require both fixed the issue. Thanks for pressing me on it! |
Thanks for taking a look at it again! Everything looks good to me! |
🚀 Issue was released in |
Describe the bug:
When using the forge-date-picker, if the minimum and maximum values span across two years, the calendar opens to the maximum value month. If the two dates are within the same year, the calendar opens to the minimum date month.
To Reproduce:
Steps to reproduce the behavior:
Expected behavior:
The calendar always defaults to the minimum value month
Please complete the following information:
The text was updated successfully, but these errors were encountered: