-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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 dropdown menu focus loss when using arrow keys with Safari and Voiceover #24186
Conversation
Size Change: +28 B (0%) Total Size: 1.15 MB
ℹ️ View Unchanged
|
Hi @talldan 👋 This is what I see before the PR: Focus is unpredictable, jumping between words and is lost after a short time. This is what I see with the fix from this PR: Focus is predictable and consistent accross all items, and focus was kept inside the dropdown, as expected. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can confirm this fixes the focus issues on dropdowns with Safari + VoiceOver
Description
Resolves the issues with dropdown menus detailed on #18537.
The
NavigableContainer
component had some specific handling that calledpreventedDefault
on key events. This function call seems to prevent Voiceover from initiating its own navigation from text content.Unfortunately this code was only checking for elements with the role
menuitem
, while the More menu also containsmenuitemradio
s and could also containmenuitemcheckbox
elements too.This PR ensures the various kinds of menu items are handled.
The second part is that when pressing left or right arrow keys, Voiceover navigates through characters. This would result in a focus loss, since it Voiceover seems to move focus to the next bit of text outside the menu, and on focus loss the menu closes unexpectedly.
Left and right arrow key presses are now also prevented. This is debatable, perhaps left should only be prevented on the first menu item, and right on the last to prevent focus leaving the menu?
How has this been tested?
Added e2e tests
Types of changes
Bug fix (non-breaking change which fixes an issue)
Checklist: