Popover (and Dropdown) needs a way to set initial focus depending on its usage or content #4620
Labels
[Focus] Accessibility (a11y)
Changes that impact accessibility and need corresponding review (e.g. markup changes).
Let's consider, for example, the "Content Structure" component (formerly "Table of Contents"). When clicking the toggle button that opens it, focus is moved to the first heading in the Document Outline. However, posts may have no headings at all:
In this case, there's no element to move focus to and a focus loss occurs. Press Tab again and focus fallbacks to the document root:
Additionally, even if there were headings, all the first part of the content (the "counts") is skipped and users of assistive technologies would have to explore content backwards to get the counts.
In this specific case, the initial focus should probably be moved to the Popover container, and the container should be properly labeled.
However, initial focus really depends on the content of the component. There might be cases where it would make sense to set the initial focus on a different element, for example an input field in a form with a very specific task to accomplish.
Since we can't predict which kind of content this component will be used for, the initial focus should be different depending on the specific component usage. I'd rather consider a way to set the initial focus via a prop, to pass in some way the element that should receive focus.
The text was updated successfully, but these errors were encountered: