Describe the bug
When you use the "changeMonth" function in a custom header, the actual month that gets selected is different dependent on the last date you clicked on. This seems to be happening when you use react-datepicker with monthsShown >= 2.
To Reproduce
I copied the below from the example docs ("Custom header with two months displayed" section) with small changes (adding a "Jump to June" button which calls changeMonth(5)). Try the following:
Click on the "Jump to June" button. It changes the display to show June on the left and July on the right. This seems correct.
Then click some day in July and reopen the calendar.
Then click the button again. The display is May on the left and June on the right. It seems react-datepicker is doing some implicit offset that makes it impossible to control which month gets displayed by passing in a target value. Now I'm trying to get June to be on the left by calling changeMonth(5) again but it won't happen. The offset seems to get worse the more calendars I put on the screen.
The only workaround seems to be some hack where I keep track of the last month I clicked and write some offset logic to fix the bug myself.
Expected behavior
Calling changeMonth(5) should always put June on the left. Jumping to a month, when in a sequence of calendars, should have a consistent defintion of what changing a month means.
Screenshots
Open the calendar.
Click the "jump to June" button
Click a day in July
Click the "jump to June" button again. Observe how June is now on the right and not the left, and July is no longer visible.
Desktop (please complete the following information):
OS: Windows
Browser: all browsers
Version: latest
Smartphone (please complete the following information):
Describe the bug When you use the "changeMonth" function in a custom header, the actual month that gets selected is different dependent on the last date you clicked on. This seems to be happening when you use react-datepicker with monthsShown >= 2.
To Reproduce I copied the below from the example docs ("Custom header with two months displayed" section) with small changes (adding a "Jump to June" button which calls
changeMonth(5)
). Try the following:changeMonth(5)
again but it won't happen. The offset seems to get worse the more calendars I put on the screen.The only workaround seems to be some hack where I keep track of the last month I clicked and write some offset logic to fix the bug myself.
Expected behavior Calling
changeMonth(5)
should always put June on the left. Jumping to a month, when in a sequence of calendars, should have a consistent defintion of what changing a month means.Screenshots
Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context N/A