-
Notifications
You must be signed in to change notification settings - Fork 432
UiCalendar: Fix prev/next month buttons when yearRange is desc
#491
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
Conversation
From UX point of view years should be sorted descending for some cases. When the custom yearRange is specified with descending array, the function breaks.
JosephusPaye
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a small change...
entioentio
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect! I was a bit concerned about this but didint think of computed as a solution
|
Just had a thought for another solution. We can assume that the year range will always be sorted, in ascending or descending order. This will save the cost of sorting a potentially big array that will probably already be sorted in the first place. So all we need is to pick the earliest and latest years using the first and last elements of the array. Then this line in const firstYear = Math.min(this.yearRange[0], this.yearRange[this.yearRange.length - 1]);
const outsideYearRange = lastDayOfPreviousMonth.getFullYear() < firstYear;Similarly this line in const lastYear = Math.max(this.yearRange[0], this.yearRange[this.yearRange.length - 1]);
const outsideYearRange = firstDayOfNextMonth.getFullYear() > lastYear; |
|
Great. I've added your min/max solution. It's elegant, cool. |
|
Let me know if you need anything more to be changed |
|
I'll merge this for the next release. Thanks! |
yearRange is desc
|
Thanks! |
|
Released in v1.3.2 |
From UX point of view years should be sorted descending for some cases. When the custom yearRange is specified with descending array, the function breaks.