react-datepicker icon indicating copy to clipboard operation
react-datepicker copied to clipboard

When displaying 2 months and having an embedded calendar, the months shift when the user selects the second calendar

Open diasqazaqbro opened this issue 1 year ago • 4 comments

Describe the bug When selecting a start date from the second calendar in a multi-month react-datepicker component, the selected month of the second calendar automatically shifts to the next month, and the focus switches back to the first calendar.

To Reproduce Steps to reproduce the behavior:

Use the react-datepicker component with monthsShown={2} and selectsRange={true}. Open the date picker and select a start date from the second calendar. Observe that the second calendar shifts its displayed month, and the focus returns to the first calendar.

Expected behavior The second calendar should remain in place, displaying the same month, and the focus should not switch to the first calendar. Both calendars should independently maintain their current view.

Screenshots

https://github.com/user-attachments/assets/27321661-e2ab-436d-97c1-a9da29ade159

Desktop: OS: Macbook M2 Browser: Chrome

Additional context This issue seems related to the focusSelectedMonth behavior, where selecting a range date causes the calendar to refocus and update its displayed month. Using a workaround with focusSelectedMonth={false} and dynamically setting it to true using a timeout not resolve this problem

diasqazaqbro avatar Dec 11 '24 12:12 diasqazaqbro

"react-datepicker": "^4.8.0",

diasqazaqbro avatar Dec 12 '24 07:12 diasqazaqbro

Hi @diasqazaqbro !

Could you share your workaround here, please?

I think that the issue #5362 I opened yesterday is related.

ludotg avatar Jan 28 '25 14:01 ludotg

Any update on this issue

hj462 avatar Apr 24 '25 22:04 hj462

@diasqazaqbro, we are facing the same issue. Were you able to fix it? Any workaround?

MobeenRashid avatar Apr 25 '25 09:04 MobeenRashid

Is this issue still reproducible? If yes can you please share a sample code snippet. I couldn't reproduce it

balajis-qb avatar Oct 14 '25 09:10 balajis-qb

@balajis-qb check if the PR fixes it?

martijnrusschen avatar Dec 04 '25 14:12 martijnrusschen

Verified @martijnrusschen 👍🏻

balajis-qb avatar Dec 05 '25 07:12 balajis-qb