-
Notifications
You must be signed in to change notification settings - Fork 758
Explain focus-visible intent and guidance. #2481
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2256,20 +2256,9 @@ The Focus-Indicated Pseudo-class: '':focus-visible''</h3> | |
| like clicking on the button with a mouse pointer. | ||
| </div> | ||
|
|
||
| <div class=advisement> | ||
| Page authors should follow these guidelines | ||
| when deciding whether to use '':focus'' or '':focus-visible'' | ||
| to style the focused state of an element: | ||
|
|
||
| * If the element has “native” focus indicator behavior | ||
| (such as text fields or buttons), | ||
| use '':focus-visible''. | ||
| * Otherwise, if the element is emulating a text input, | ||
| or something else that is <em>intended</em> to receive keyboard interaction, | ||
| use '':focus''. | ||
| * Otherwise, | ||
| use '':focus-visible''. | ||
| </div> | ||
| This pseudo-class is intended to give developers the ability to style focus | ||
| selectively, in order to encourage visible, usable focus styles, and | ||
|
||
| discourage the practice of disabling the default user agent focus style. | ||
|
|
||
| When UAs choose to specially indicate focus on an element, | ||
|
||
| or whether they specially indicate focus at all, | ||
|
|
@@ -2280,19 +2269,34 @@ The Focus-Indicated Pseudo-class: '':focus-visible''</h3> | |
| but with different user settings, | ||
| can make different choices as to when an element matches '':focus-visible''. | ||
|
|
||
| <div class=example> | ||
| The following guidelines are suggested heuristics | ||
| for choosing when to apply '':focus-visible'' | ||
| to elements without “native” focus indicator behavior: | ||
|
|
||
| * If the element received focus via a keyboard interaction, | ||
| including indirectly, | ||
| such as triggering a dialog | ||
| by pressing a button using the keyboard, | ||
| apply '':focus-visible''. | ||
| * If a keyboard event occurs while an element is focused, | ||
| even if the element wasn't focused by a keyboard interaction, | ||
| apply '':focus-visible''. | ||
| Since part of the problem is user agents' default focus indicator behaviour, | ||
|
||
| it is recommended that browsers implementing the `:focus-visible` | ||
| selector also use it in their user agent stylesheets to show the default focus | ||
|
||
| indicator. | ||
|
|
||
| <div class=note> | ||
| The user agent should take into account the available signals as to whether | ||
| the user might find focus indication useful. The result of these heuristics | ||
| must determine whether `:focus-visible` should match on the currently | ||
| focused element. | ||
|
|
||
| By default, if there are no signals indicating that focus should be | ||
| indicated, then focus SHOULD NOT be indicated on the focused element, unless | ||
| the user has expressed a preference for always seeing a focus ring. | ||
|
|
||
| The following may be considered signals: | ||
|
|
||
| * An element which requires the use of a keyboard, such as a text input, | ||
| SHOULD always have a visible focus indicator. | ||
| * If a user is using keyboard-based navigation by using the tab and arrow | ||
| keys, the focused element SHOULD be indicated. | ||
| * If a user is interacting with an element via the keyboard (such as | ||
| incrementing or decrementing using the arrow keys, or using the spacebar to | ||
| activate a button) the focused element SHOULD be indicated. | ||
| * Note that keyboard interaction may trigger focus to be moved | ||
| programmatically, and this may be considered an extension of the original | ||
| keyboard interaction. | ||
|
|
||
| </div> | ||
|
|
||
| <h3 id="the-focus-within-pseudo"> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems a little disappointing to remove all of the advice for authors. It's not clear to me that the old advice was the best that could be offered, but this does seem like an area where it's worth offering some expert advice on what the right thing really is.