amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

amp-carousel: Insufficient focus indication (outline color contrast)

Open TetraLogicalHelpdesk opened this issue 6 years ago • 1 comments

WCAG Level

Level AA

Priority

High

Type

Colour, Navigation

Pages/screens/Components affected

Description

Keyboard users rely on the browser's focus outline to keep track of where they are on web pages. The currently selected form input, button, or hyperlink is the one said to have the focus.

Most browsers use a faint dotted outline to indicate the focus to the user, though some browsers like Chrome or Safari use an enhanced focus outline, consisting of a coloured border around the selected link. It is also possible for developers to provide custom focus indications within the site's cascading style sheets (CSS).

In the case of the <amp-carousel>, by default the previous/next buttons rely on the default browser outline as focus indication. In some browsers like Chrome, which has recently introduced a more visible two-colour focus ring (see Chromium blog: Updates to form controls and focus), this approach works great, and the focus indication remains clearly visible and contrasting.

Current focus indication in Chrome for the next button

However, in browsers such as Firefox (which only use a dotted outline with the element's defined color by default), the focus indication can - depending on the content in the carousel/slide, become very low contrast (with contrast falling below the 3:1 threshold required for WCAG 2.1 SC 1.4.11 Non-text Contrast), or can be completely invisible (if the content of the carousel matches the actual colour of the outline exactly).

Current focus indication in Firefox for the next button - virtually invisible

Taking the above example, contrast between the outline in Firefox (approximately #030609) and parts of the image-based slide content (taking #0D2C41 as an average value) is 1.4:1, far below the required 3:1.

Normatively WCAG 2.1 SC 2.4.7 Focus Visible does not define what constitutes "visible", so this SC would only officially fail in situations where the carousel content exactly matches the current colour of the default focus indicator in Firefox. However, for situations where focus is "visible" but has very low contrast, this will normatively fail WCAG 2.1 SC 1.4.11 Non-text Contrast. While SC 1.4.11 does have a clause that exempts elements

where the appearance of the component is determined by the user agent and not modified by the author

this does not apply in this case, as the appearance of the element has been styled/modified using CSS already, thus making focus indication the responsibility of the author/developer.

User impact

Without a visible focus indicator it can be difficult or impossible for keyboard users that aren't using additional assistive technology such as a screen reader to know which control (whether it be a link, button, or something else) currently has focus and therefore what action will take place if they press the Enter, Space, or other keys.

Required solution

Make sure that all focusable elements have a clear focus style, and that this style has sufficient contrast against any potential background.

As it's not possible at the outset to determine whether the carousel content will be light or dark - thus making it impossible to settle on one specific colour that will always guarantee sufficient contrast - we recommend replicating the approach taken by Chrome recently and providing a dual-colour border/outline combination.

.amp-carousel-button:focus {
    border: 1px black solid;
    outline: 1px white solid;
}

Different options are available. For instance, an outline could be shown on focus inside the button. Or the arrow inside the button could visually change (e.g. become noticeably bolder/fatter) when focused. The specific approach chosen will depend on aesthetic decisions, but ultimately it must be "visible" and, if it relies on non-text elements such as borders or outlines, the contrast of the indicator must have a contrast of 3:1 or better against adjacent colours.

To only make these styles apply for keyboard users, it is possible to use :focus-visible instead of :focus. However, support for this is still not pervasive across browsers, and will require the use of a workaround, such as the WICG focus-visible polyfill.

Test procedure(s)

Use these steps to confirm that the solution has been correctly applied:

  1. Use a browser such as Firefox which has does not have a highly visible default focus indication.
  2. Navigate to a focusable component on the page using the keyboard (Tab/Shift+Tab).
  3. Check that the focus indicator is visible against any possible carousel content.
  4. Using a tool such as the TPG: Colour Contrast Analyser verify that the contrast between the focus indicator and its adjacent background is at least 3:1.

Definition of done

Complete all of these tasks before closing this issue or indicating it is ready for retest:

  • All issues identified within the test sample have been resolved.
  • The rest of the website has been tested for the same issue.
  • All issues identified throughout the website have been resolved or filed as new issues.

Related standards

More information

Test data

Test date: July 2020

TetraLogicalHelpdesk avatar Jul 29 '20 10:07 TetraLogicalHelpdesk

Looking into this.

dmanek avatar Oct 19 '20 21:10 dmanek