Skip to content

Commit 86a97d1

Browse files
patrickhlaukeXhmikosR
authored andcommitted
Remove indiscriminate outline suppression for tabindex="-1" elements (#28437)
instead, only apply outline suppression if the browser wouldn't normally apply the focus outline, using the (currently experimental) `:focus-visible` pseudo-class
1 parent 87527d8 commit 86a97d1

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

scss/_reboot.scss

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,16 @@ body {
5454
background-color: $body-bg; // 2
5555
}
5656

57-
// Suppress the focus outline on elements that cannot be accessed via keyboard.
58-
// This prevents an unwanted focus outline from appearing around elements that
59-
// might still respond to pointer events.
60-
//
61-
// Credit: https://github.com/suitcss/base
62-
[tabindex="-1"]:focus {
57+
// Future-proof rule: in browsers that support :focus-visible, suppress the focus outline
58+
// on elements that programmatically receive focus but wouldn't normally show a visible
59+
// focus outline. In general, this would mean that the outline is only applied if the
60+
// interaction that led to the element receiving programmatic focus was a keyboard interaction,
61+
// or the browser has somehow determined that the user is primarily a keyboard user and/or
62+
// wants focus outlines to always be presented.
63+
//
64+
// See https://developer.mozilla.org/en-US/docs/Web/CSS/:focus-visible
65+
// and https://developer.paciellogroup.com/blog/2018/03/focus-visible-and-backwards-compatibility/
66+
[tabindex="-1"]:focus:not(:focus-visible) {
6367
outline: 0 !important;
6468
}
6569

0 commit comments

Comments
 (0)