You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With the following configs, the decades view is initially shown but when you select the focused decade (1920 in this case), the subsequent focused year is the first year of the selected decade (1920) and not the year in defaultViewDate (1922).
The default view date is not the start view date. The start view date is the last selected date, and if no dates are selected, then the default view date is used as a fallback.
I recommend trying selecting a date in a different century and decade from the defaultViewDate's and see what happens.
In my example, there is no selected date, so it's the defaultViewDate that should be start view date. The key to the issue here is having a startView of 3 (decades), which then makes the incorrect year selection.
It's even evident with no defaultViewDate set, when the current date expected. Here's an example using your online demo with only startView set as 3. You'd expect today's date (06/17/2024) to be focused when using the datepicker but it's actually 06/17/2020 that is focused. Am I still missing something here?
I'm so sorry, it's me who misunderstood. I didn't read carefully and thought you were talking about the behavior after setting a date in 1920 as a selected date.
It's indeed a bug, and inconsistent with the behavior of other views. So, I'll include the fix for this in the next update.
Thank you for reporting the bug. And my apologies for being careless.
With the following configs, the decades view is initially shown but when you select the focused decade (
1920
in this case), the subsequent focused year is the first year of the selected decade (1920) and not the year indefaultViewDate
(1922).At first glance, it seems to be due to the year and decade sharing the same view in
YearsView
, withnavStep
set incorrectly for the year view (but correctly for the decade view).https://github.com/mymth/vanillajs-datepicker/blob/master/js/picker/views/YearsView.js#L18
The text was updated successfully, but these errors were encountered: