-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
[List] Add keyboard navigation #15334
Conversation
@mbrookes Why should a list have keyboard support? Is the tab the correct way to navigate within a list (ul / li)? |
You might be right. I was applying the principals described here: "A primary keyboard navigation convention common across all platforms is that the tab and shift+tab keys move focus from one UI component to another while other keys, primarily the arrow keys, move focus inside of components that include multiple focusable elements." And in 5.6 Keyboard Navigation Inside Components This allows skipping past the nav with a single Tab, and has the added benefit that the active list-item (if any) can receive focus when tabbing onto the list. (See: 5.6.1 Managing Focus Within Components Using a Roving tabindex). The question then is, should a nav be a composite component? It certainly seems better for accessibility, and yet that very page does not treat its TOC as a composite component... |
Benchmarking: https://material-components.github.io/material-components-web-catalog/#/component/list - composite Others? |
Thank you for sharing relevant sections of the accessibility guidelines.
There is no mention to a ul>li structure as a popular candidate. I don't think that we should provide this feature to the list by default. Now, they mention the tab. It's something I was talking about with @nathanmarks a long time ago. Maybe we can abstract the menu focus logic, use it in the tabs and possibly make it public to be used somewhere else? |
HTML lists aren't inherently navigable, so it's understandable that they're not mentioned. However, the use of an unordered list for semantic "correctness" in a composite list component that is navigable changes that. |
I don't understand this either. A basic list should not be navigateable since the items don't have an associated action. It might make sense for a nav or a ToDo list but just listing things does not require keyboard navigation. It's just text in the end. In other words: If the items are not focusable there's no need for keyboard navigation. |
I still think that this change could help people. Take Gmail, their left side menu implements this behavior (Google keep and Google Contacts don't). It's also related to #15107. |
This behaviour is awesome if the list contains clickable elements, however how does the implementation handle lists without clickable elements. I don't see any special treatment for those? |
@Pajn Please point me to an example in the spec of a non-interactive list item (other than a disabled list item, of course). They are by definition "clickable":
|
I see we switched roles here 😉 But I did misjudge the implementation. If the list contains no interactive items then you won't get keyboard navigation anyway. So this is actually super nice behavior that emerges. One issue is that it doesn't work for https://deploy-preview-15334--material-ui.netlify.com/demos/lists/#checkbox. Maybe due to the nested action item? Maybe just needs some adjustments in the demo. |
Well, you did at least 😉
Good catch! I'll take a look and see if there's an easy fix. |
Discussion draft - applies the same logic to
List
as currently used inMenuList
.Not resolved:
(Not that MenuList currently supports these either.)