Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keyboard accessibility navigation not working on MonthYearPicker #4400

Closed
Orhan92 opened this issue Nov 30, 2023 · 1 comment · Fixed by shini4i/argo-watcher#317 · May be fixed by limzengkai/PLMM-Tuition-Centre#5
Closed

Comments

@Orhan92
Copy link

Orhan92 commented Nov 30, 2023

Describe the bug
It is not possible to navigate with keyboard navigation in the YearMonthPicker. When I click on the input field there is no way to use keyboard navigation to navigate through the calendar. This is not considered accessible and there is no way for the user to navigate to the calendar without first clicking on it. It works like a charm in the standard calendar with dates but not in MonthYearPicker.

To Reproduce
Steps to reproduce the behavior:

  1. Use prop: showMonthYearPicker
  2. Try to navigate with keyboard

Expected behavior
When calendar pops up the user should be able to navigate through the calendar with keyboard. In other words, when the input field is clicked on or selected, keyboard navigation should set focus on the calendar.

Desktop (please complete the following information):

  • OS: Windows 10/11
  • Browser: Chrome:latest / Firefox:latest

Additional context
Is there any solution to this applied in the repo or is it actually a bug?

@lasseklovstad
Copy link
Contributor

lasseklovstad commented Apr 15, 2024

Added a pr to hopefully fix this. Temporary fix i'm using to allow up/down arrow key focus first month:

<DatePicker
        onKeyDown={(e) => {
          if (!(e.target instanceof HTMLInputElement)) {
            return;
          }

          const eventKey = e.key;

          if (eventKey === "ArrowDown" || eventKey === "ArrowUp") {
            e.preventDefault();
            const selector = ".react-datepicker__month-text[tabindex='0']";
            const selectedItem =
              document.querySelector<HTMLDivElement>(selector);
            selectedItem && selectedItem.focus();
          }
        }} />
```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants