-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
Describe the bug
When you open the calendar and use the arrow keys to navigate to a new day, the focused element does not change.
This has 2 important consequences that I'm aware of:
-
Screen-reader accessibility for the calendar is broken. When screen-reader user uses arrow-key to navigate to a new day, there will be 0 announcements.
-
:focusand:focus-visiblepseudo-selectors will not apply to a day that has been selected via arrow keys.
To Reproduce
Steps to reproduce the behavior:
-
run the following script:
function printFocusedElement() { console.log(document.activeElement); setTimeout(printFocusedElement, 2000); } printFocusedElement(); -
Use an arrow-key to navigate to a new day in react-datepicker calendar
-
Note that the focused element being logged has not changed
Expected behavior
When you use arrow-key to navigate to a day, that day should be focused.
Screenshots
In this screenshot, I have navigated from February 19th --> February 17th via arrow-keys, but February 19th is still the focused element.

Desktop (please complete the following information):
- OS: [Windows]
- Browser [Chrome]
- Version [132.0.6834.197]
Additional context
This behavior first appears in react-datepicker v7.0.0
This only applies when using arrow keys to navigate between days in the same month. The focus is still applied correctly when you navigate from a day in month X to a day in Month Y using arrow-keys.
Additionally, if you tab from the next-month button to the day, it will be focused correctly.
(ex:
navigate to a from May 20 to May 19 via arrows. May 19 will not be focused.
hit TAB. You are now on the 'previous-month' button.
hit TAB again. You are now on 'next-month' button.
hit TAB again. You are now on May 19, and now it it focused.
)