-
Notifications
You must be signed in to change notification settings - Fork 213
Description
The focusgroup explainer interactive content inside focusgroups section describes that some elements like <input type="number">
or <input type="number">
already have actions assigned to arrow keys that conflict with the focusgroup navigation. There is a list of potential solutions to this issue in the explainer.
Fortunately, there are several solutions to this problem:
- Remove tabindex=-1 from the “Increase/Decrease Font” buttons.
- Move the “Increase/Decrease Font” buttons before the combobox. (Refer to “Avoid including controls whose operation requires the pair of arrow keys used for toolbar navigation” in the Toolbar control pattern.) Additionally, opt-out the control from focusgroup participation so that arrow keys skip it. Alternatively, turn off the focusgroup’s memory so that focus isn’t automatically returned to the combobox.
- Use script to intercept focusgroup-related keydown events on the and move focus manually. Also consider limiting the focusgroup to one axis and reserving the other axis for operating the
<input>
.
I'd like to propose another approach that would provide a default behaviour that can be enhanced by authors.
Turning off roving behaviour when a key conflict element gets focused
It's best explained with a demo: https://gfellerph.github.io/focusgroup-polyfill/. The first example "regular focusgroup" in this experimental implementation has an input field amongst other focusable elements inside the focusgroup. The memory functionality is on. However, when the input field is focused by arrow key navigation, the memory functionality on all other focusgroup candidates is turned off. Tab or shift tab leaves the input field and focuses the next focusable element in either direction. If this is a focusgroup candidate and not a key conflict element, memory behaviour is restored. Tabbing again will leave the focusgroup. The key conflicting <input>
can never be the memory element. To change the behaviour, the following options are (still) available:
- Skipping over the input when navigating with arrow keys can be achieved by setting
<input focusgroup="none">
- Disabling the arrow keys on input fields and other elements that already use arrow keys for other actions is left to the author
- Disabling memory behaviour enables all tab stops
This approach would provide a default way of handling this edge case when none of the above solutions are implemented.