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

Fix bug with keyboard navigation #616

Open
wants to merge 1 commit into
base: v3
Choose a base branch
from
Open

Fix bug with keyboard navigation #616

wants to merge 1 commit into from

Conversation

il97mur
Copy link

@il97mur il97mur commented May 30, 2024

This PR fixes the bug in datepicker keyboard navigation.

The sandbox link: https://codesandbox.io/p/sandbox/sweet-pine-pwmcnk

Steps to reproduce:

  1. Set focus into the datepicker input.
  2. Navigate to previous focusable element with "shift + tab".
  3. Return focus to the input.
  4. Try to use arrows to navigate between cells. The datepicker will change years instead of navigating between cells.

The reason of described behaviour is that the "shift" key still in the pressedKeys set when datepicker input loses focus (by pressing shift+tab) because the keyup event with "shift" key will be fired after the input will lose the focus and onKeyUp input handler will be not fired.

The solution:

  1. Add blur event listener on input on keyboard navigation initialization.
  2. Input blur event handler will clear the pressedKeys set.

Copy link

vercel bot commented May 30, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
air-datepicker ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 30, 2024 6:16am

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

Successfully merging this pull request may close these issues.

1 participant