amp-list: Redundant/unnecessary keyboard focus stops
WCAG Level
Level A
Priority
Low
Type
Navigation
Pages/screens/Components affected
Description
For people who navigate using a keyboard or keyboard-like device (such as a switch control or a joystick) the focus order of interactive controls in a document should be logical and intuitive.
By default, when using <amp-list> to output a list of non-interactive elements (as in the example for the Specifying an overflow section), the rendered output automatically makes all list items keyboard-focusable by adding tabindex="0".
Using a basic format of
<amp-list width="auto" height="100" src=".../amp-list-data.json">
<template type="amp-mustache">
{{title}}
</template>
</amp-list>
the resulting rendered output is
<div role="list" class="...">
<div role="listitem" tabindex="0">
...
</div>
<div role="listitem" tabindex="0">
...
</div>
...
</div>
Note that this incorrect/inappropriate behaviour does not happen when the template does include a focusable element, such as a link. The following AMP markup
<amp-list width="auto" height="100" src="/static/inline-examples/data/amp-list-urls.json">
<template type="amp-mustache">
<div>
<a href="{{url}}">{{title}}</a>
</div>
</template>
</amp-list>
results in correctly rendered output (note the absence of tabindex="0" on the list items)
<div role="list" class="i-amphtml-fill-content i-amphtml-replaced-content">
<div role="listitem">
<a target="_top" href="...">...</a>
</div>
<div role="listitem">
<a target="_top" href="...">...</a>
</div>
...
</div>
User impact
Duplicate/unnecessary tab stops are likely to cause irritation for keyboard-only users when they are navigating through the page because it means they have to use twice as many key presses to get where they want to go. For people using an alternative input device like a head-wand (that mimics keyboard interaction) the duplicated effort can even cause fatigue. Further, if elements that are not interactive receive focus, this may lead users to think that the elements are actionable - when attempting to activate them has no effect, this may lead to further confusion.
Required solution
While authors can explicitly override this behaviour by adding tabindex="-1" to their template, this should not be required - the tabindex="0" should not be generated by default.
Make sure that only actionable controls fall into the regular keyboard focus order. When generating the rendered list, do not forcibly add tabindex="0" attributes to list items.
Test procedure(s)
Use these steps to confirm that the solution has been correctly applied:
- Use
TAB/SHIFT+TABto navigate through the page. - Check that non-interactive/non-functional controls don't fall into the focus order.
Related standards
Test data
Test date: July 2020
+1 for this. I've noticed on our sites that there's a few instances where there's extra tabbing due to this.