This repository was archived by the owner on May 29, 2019. It is now read-only.
fix(datepicker): correctly change months #1701
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes #1697
The problem is that when we have let's say day 30 of January and we do a
setMonth
to change it to February, since February doesn't have 30 days,setMonth
will try to fix it selecting the last day available (28) and then adds the rest of days, so it will selectMarch 02
. That is why it skips the month.I also tested going back, from
March 30
toFebruary
It fails, it doesn't skip the month, it directly doesn't change. (Same problem,setMonth
would try to put February but when it adds the two extra days, it ends on March, so it doesn't change). Clicking again changes ok (Because the selected date will have2
as the day).Anyway, since we need
selected
for calendar purposes (not for the selected date) we can just put the day as the day1
(so no month can cry) when we move through months. That way you won't skip months anymore.