Skip to content
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

Remove anchor focus override within dropdown menu #23990

Merged
merged 2 commits into from Sep 30, 2017

Conversation

arizzitano
Copy link
Contributor

@arizzitano arizzitano commented Sep 18, 2017

The dropdown styles explicitly remove the browser's default focus outline for links within the menu, which hurts accessibility as it violates WCAG 2.0 AA section 2.4.7 [edit: technically, the focus highlight background color prevents it from failing]. Without the focus outline, keyboard-only users cannot orient themselves within a dropdown menu, which can be especially troublesome if the implementor has also applied a focus trap.

This PR removes the override, enabling the browser to apply its own native focus outline to links within the dropdown menu. The outline will only appear if a link has :focus, so mouse users will see virtually no change.

Suggestions welcome -- happy to amend as necessary!

Screenshots

Before After
image image

Overriding the focus outline for links within the dropdown menu
causes accessibility issues for keyboard-only users. This
removes the override, reenabling the browser's default focus
outline.
@patrickhlauke
Copy link
Member

to clarify, no: the current situation does not fail wcag 2 2.4.7 as there is a visible focus indication (the background color applied to focused dropdown item). you can argue about whether or not the focus indication itself could be stronger, but as it stands it does nominally pass 2.4.7

@arizzitano
Copy link
Contributor Author

arizzitano commented Sep 18, 2017

I updated the description accordingly, but I stand by the override removal. It's entirely reasonable for users to expect a focus outline on links, since that's a browser default. Is there a reason for keeping the override?

Regarding the background highlight, the dropdown still fails 2.4.7 in high-contrast mode (all modes on Windows; all but the lowest setting on OSX).

@andresgalante
Copy link
Collaborator

I don't know about wcag 2 2.4.7, but I think that a focus ring can be stronger.

@tmorehouse
Copy link
Contributor

I too agree that the current dropdown focus background is rather light, and depending on screen contrast is almost invisible. I have had keyboard only users complain about the inability to tell which dropdown item they have focused (screen readers users are OK with it).

We have added a box shadow with a large spread to darken the focus highlight. Non keyboard users didn't like the focus ring we applied, so we went with a darker background.

@arizzitano
Copy link
Contributor Author

Just to be clear, this native focus ring will not show up for non-keyboard users. It only appears when focus is applied via the keyboard (or programmatically), and doesn't affect the hover state at all.

@patrickhlauke
Copy link
Member

LGTM. @mdo ?

@patrickhlauke
Copy link
Member

patrickhlauke commented Sep 21, 2017

xref #23329

@tmorehouse
Copy link
Contributor

This addresses link dropdown items, but not button dropdown items.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
v4 Beta 2
Shipped
Development

Successfully merging this pull request may close these issues.

None yet

7 participants