-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Popover: focusOnMount shouldn't be specific to keyboard interaction #5559
Comments
In retrospect, I can agree with this point. The problem I'd encountered, as demonstrated in the "Before" screenshots of #5318, is that the styling applied in shifting focus to the first item can confuse intention between states of selection and focus. Perhaps to address this (and arguably for better consistency with other similar native UIs), could it be that opening the menu would still shift focus to the popover, but to its container, not the first item? Then the user could still proceed to tab/arrow would navigate options in the list. In the meantime, I would be fine to revert #5318, and can plan to take a look at an alternate implementation this week. |
The Finder example works a bit differently when using the keyboard:
Of course, finder is a desktop application and works differently from a web application, but this behavior is more similar to what we've described a few times for toggles and panels: ideally, the expanded panel (or popup, whatever we want to call it) should immediately follow the control that opened it. This way, it is just placed in the natural tab order. Instead, when it's placed far in the source, there's the need to manage focus. I can only refer to the expected behaviors listed in the ARIA authoring practices for similar UIs and they all ask to set initial focus on an element inside the panel/menu/dialog: https://www.w3.org/TR/wai-aria-practices/#menubutton
https://www.w3.org/TR/wai-aria-practices/#dialog_modal
The issue in #5318 seems to me a styling issue, can we try to solve it on the styling side, trying to clearly differentiate the "fcused" and "active" styles? |
For completeness, looking at similar UI on Windows (Windows 10 Task Manager window): when opening a menu with the mouse, focus is not moved inside the menu (but then using the arrows, focus moves to the menu items): Instead, when opening the same menu with the keyboard, focus is moved to the first menu item: I'd rather keep it simple though, and meet the ARIA authoring practices. |
The full context of the quote is in pressing Enter/Space/Up/Down while the button is already focused:
Assuming the act of clicking on the button as its focusing, would it then not stand to reason the first menu item would only become focused after then proceeding to press one of these keys? |
To be honest, mouse interaction is not described in the ARIA authoring practices. I see their examples (there are a few linked on the menu and menubar sections) work differently with mouse; they all reveal the menu on hover 😬 Just some of them work on mouse click too and move focus to the first menu item: I'd rather try to keep the functionality as simple as possible, without assumptions. Styling issues should be solved on the presentation side. |
The simplest approach would be to assume that the button should first become focused, then navigation to menu item occurs when proceeding to press one of the above-mentioned buttons. |
Technically, the button receives focus while it's clicked. I'd also consider the advantage given by removing those 2 keyboard events attached to the document.
In that case, it should work also with the Tab key. |
Precisely, so the first step is satisfied. The user can then press [some aforementioned button] to navigate to the first item in the list. I intentionally avoided mention of interaction device in my previous comment to align behaviors on "in focus, and out of focus". |
Just tested again and went a bit in depth. Interestingly (and I should have noted this before) when a screen reader is running, DOM events (especially keyboard events) may not work the way one would expect. This happens especially with keyboard events attached to elements that are not focusable or don't have a specific ARIA role. Note: the same issue happens in a few places in core, see this Trac ticket: https://core.trac.wordpress.org/ticket/34668#comment:3 Tested with: and the Reproducing the issue is simpler on Windows but can be done also with Safari and VoiceOver (needs just a minute to be reproduced), just be sure to use the right keys combination:
Regardless of the fact VoiceOver asks to use I've also dumped to the console the In the screenshot above you can see:
Sorry for the long explanation but this is an important point to keep in mind. Given that moving focus fails for one of the users group it's specifically intended to work for, I'd propose to just remove the check for |
Related: #5595 |
Many users are not exclusively "mouse users" or "keyboard users". Actually, many users make a mixed use of mouse and keyboard. Implementing software features that work just with mouse or keyboard interaction, is often just an assumption.
In the Popover component there's some code intentionally used to move focus to the Popover only when a keyboard is used.
This seems to me a big assumption, as focus should always be moved to the Popover regardless of the device used. Anecdotally, I personally often make a mixed use of mouse and keyboard, as that's the fastest way to interact with an interface for me. I'm pretty sure I'm not the only one.
So what happens with the Popover? Let's consider one of the Popover implementations: the more options menu. When using the mouse (screenshot on the left) focus is not moved to the Popover. Instead, when using a keyboard (screenshot on the right) focus is moved to the Popover:
This doesn't allow mixed use of mouse and keyboard: for example, users might want to click to open the menu and then quickly use the Tab key to select a menu item. Users often find unexpected ways to interact with an UI, an the UI shouldn't make any assumption on the expected behaviors.
I don't see a good reason for this distinction between mouse and keyboard interaction other than the will to not display the focus style on the first item. If this is the case, I'd like to remind everyone the focus style is a native accessibility feature that should always work for all users, regardless of the device they use.
From a technical perspective, removing this different behavior would also help in reducing the number of keyboard events used in Gutenberg, which have recently come to a point where they seem rather convoluted and fragile. /cc @aduth
The text was updated successfully, but these errors were encountered: