Skip to content

Arrow-navigation in calendar does not change focus, breaking accessibilityΒ #5428

@John-Feola

Description

@John-Feola

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:

  1. 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.

  2. :focus and :focus-visible pseudo-selectors will not apply to a day that has been selected via arrow keys.

To Reproduce
Steps to reproduce the behavior:

  1. run the following script:
    function printFocusedElement() { console.log(document.activeElement); setTimeout(printFocusedElement, 2000); } printFocusedElement();

  2. Use an arrow-key to navigate to a new day in react-datepicker calendar

  3. 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.
Image

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.
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions