Skip to content

Commit

Permalink
Use focus-visible for focus indicator heuristics (#1332)
Browse files Browse the repository at this point in the history
  • Loading branch information
ianmcburnie authored Jan 13, 2021
1 parent 9475281 commit 465b7ae
Show file tree
Hide file tree
Showing 75 changed files with 345 additions and 75 deletions.
4 changes: 4 additions & 0 deletions dist/breadcrumbs/ds4/breadcrumbs.css
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ nav.breadcrumbs button[aria-current] {
color: var(--breadcrumbs-item-current-foreground-color, #767676);
text-decoration: none;
}
nav.breadcrumbs a:focus:not(:focus-visible),
nav.breadcrumbs button:focus:not(:focus-visible) {
outline: none;
}
@media (min-width: 601px) {
nav.breadcrumbs {
margin: 16px 0;
Expand Down
4 changes: 4 additions & 0 deletions dist/breadcrumbs/ds6/breadcrumbs.css
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ nav.breadcrumbs button[aria-current] {
color: var(--breadcrumbs-item-current-foreground-color, #767676);
text-decoration: none;
}
nav.breadcrumbs a:focus:not(:focus-visible),
nav.breadcrumbs button:focus:not(:focus-visible) {
outline: none;
}
@media (min-width: 601px) {
nav.breadcrumbs {
margin: 16px 0;
Expand Down
4 changes: 4 additions & 0 deletions dist/button/ds4/button.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ a.fake-btn--truncated span {
text-overflow: ellipsis;
white-space: nowrap;
}
button.btn:focus:not(:focus-visible),
a.fake-btn:focus:not(:focus-visible) {
outline: none;
}
button.btn--wide,
a.fake-btn--wide {
padding-left: 48px;
Expand Down
4 changes: 4 additions & 0 deletions dist/button/ds6/button.css
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ a.fake-btn--truncated span {
text-overflow: ellipsis;
white-space: nowrap;
}
button.btn:focus:not(:focus-visible),
a.fake-btn:focus:not(:focus-visible) {
outline: none;
}
button.btn--wide,
a.fake-btn--wide {
padding-left: 48px;
Expand Down
6 changes: 6 additions & 0 deletions dist/carousel/ds4/carousel.css
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ div.carousel {
color: #333;
color: var(--carousel-paddle-foreground-color, #333);
}
.carousel__control:focus:not(:focus-visible) {
outline: none;
}
@media (min-width: 601px) {
.carousel:focus-within .carousel__control {
opacity: 0.92;
Expand Down Expand Up @@ -152,6 +155,9 @@ div.carousel {
.carousel__control:active {
background-color: #333;
}
.carousel__playback:focus:not(:focus-visible) {
outline: none;
}
span.carousel,
span.carousel__container {
display: inline-block;
Expand Down
6 changes: 6 additions & 0 deletions dist/carousel/ds6/carousel.css
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ div.carousel {
color: #111820;
color: var(--carousel-paddle-foreground-color, #111820);
}
.carousel__control:focus:not(:focus-visible) {
outline: none;
}
@media (min-width: 601px) {
.carousel:focus-within .carousel__control {
opacity: 0.92;
Expand Down Expand Up @@ -160,6 +163,9 @@ div.carousel {
.carousel__control:active {
background-color: #414141;
}
.carousel__playback:focus:not(:focus-visible) {
outline: none;
}
span.carousel,
span.carousel__container {
display: inline-block;
Expand Down
10 changes: 7 additions & 3 deletions dist/checkbox/ds4/checkbox.css
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,16 @@ input.checkbox__control[type="checkbox"]:checked + span.checkbox__icon svg.check
input.checkbox__control[type="checkbox"]:checked + span.checkbox__icon svg.checkbox__unchecked {
display: none;
}
input.checkbox__control[type="checkbox"]:focus + span.checkbox__icon {
outline: 1px dotted #767676;
}
input.checkbox__control[type="checkbox"][disabled] + span.checkbox__icon {
opacity: 1;
}
input.checkbox__control[type="checkbox"][disabled] + span.checkbox__icon svg {
fill: #ccc;
}
input.checkbox__control[type="checkbox"]:focus + span.checkbox__icon {
outline: 1px auto #767676;
outline-offset: 2px;
}
input.checkbox__control[type="checkbox"]:focus:not(:focus-visible) + span.checkbox__icon {
outline: none;
}
10 changes: 7 additions & 3 deletions dist/checkbox/ds6/checkbox.css
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,16 @@ input.checkbox__control[type="checkbox"]:checked + span.checkbox__icon svg.check
input.checkbox__control[type="checkbox"]:checked + span.checkbox__icon svg.checkbox__unchecked {
display: none;
}
input.checkbox__control[type="checkbox"]:focus + span.checkbox__icon {
outline: 1px dotted #767676;
}
input.checkbox__control[type="checkbox"][disabled] + span.checkbox__icon {
opacity: 1;
}
input.checkbox__control[type="checkbox"][disabled] + span.checkbox__icon svg {
fill: #c7c7c7;
}
input.checkbox__control[type="checkbox"]:focus + span.checkbox__icon {
outline: 1px auto #767676;
outline-offset: 2px;
}
input.checkbox__control[type="checkbox"]:focus:not(:focus-visible) + span.checkbox__icon {
outline: none;
}
3 changes: 3 additions & 0 deletions dist/cta-button/ds4/cta-button.css
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ a.cta-btn--truncated span {
text-overflow: ellipsis;
white-space: nowrap;
}
a.cta-btn:focus:not(:focus-visible) {
outline: none;
}
a.cta-btn:visited {
color: #333;
color: var(--cta-button-visited-foreground-color, #333);
Expand Down
3 changes: 3 additions & 0 deletions dist/cta-button/ds6/cta-button.css
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ a.cta-btn--truncated span {
text-overflow: ellipsis;
white-space: nowrap;
}
a.cta-btn:focus:not(:focus-visible) {
outline: none;
}
a.cta-btn:visited {
color: #111820;
color: var(--cta-button-visited-foreground-color, #111820);
Expand Down
3 changes: 3 additions & 0 deletions dist/details/ds4/details.css
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,6 @@ details.details[open] span.details__icon {
details.details[open] summary.details__summary::before {
content: none;
}
details.details summary:focus:not(:focus-visible) {
outline: none;
}
3 changes: 3 additions & 0 deletions dist/details/ds6/details.css
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,6 @@ details.details[open] span.details__icon {
details.details[open] summary.details__summary::before {
content: none;
}
details.details summary:focus:not(:focus-visible) {
outline: none;
}
3 changes: 3 additions & 0 deletions dist/drawer-dialog/ds4/drawer-dialog.css
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,6 @@ button.drawer-dialog__close {
-webkit-transform: translateX(0);
transform: translateX(0);
}
.drawer-dialog__handle:focus:not(:focus-visible) {
outline: none;
}
3 changes: 3 additions & 0 deletions dist/drawer-dialog/ds6/drawer-dialog.css
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,6 @@ button.drawer-dialog__close {
-webkit-transform: translateX(0);
transform: translateX(0);
}
.drawer-dialog__handle:focus:not(:focus-visible) {
outline: none;
}
3 changes: 3 additions & 0 deletions dist/expand-button/ds4/expand-button.css
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ button.expand-btn--truncated span {
text-overflow: ellipsis;
white-space: nowrap;
}
button.expand-btn:focus:not(:focus-visible) {
outline: none;
}
button.expand-btn:hover,
button.expand-btn:focus {
border-color: #00489f;
Expand Down
3 changes: 3 additions & 0 deletions dist/expand-button/ds6/expand-button.css
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ button.expand-btn--truncated span {
text-overflow: ellipsis;
white-space: nowrap;
}
button.expand-btn:focus:not(:focus-visible) {
outline: none;
}
button.expand-btn:hover,
button.expand-btn:focus {
border-color: #2b0eaf;
Expand Down
6 changes: 6 additions & 0 deletions dist/filter-button/ds4/filter-button.css
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,9 @@ a.filter-link--selected:not([href]):hover,
a.filter-link--selected[aria-disabled="true"]:hover {
background-color: #dbeafe;
}
/* stylelint-disable no-descending-specificity */
button.filter-button:focus:not(:focus-visible),
a.filter-link:focus:not(:focus-visible) {
outline: none;
}
/* stylelint-enable no-descending-specificity */
6 changes: 6 additions & 0 deletions dist/filter-button/ds6/filter-button.css
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,9 @@ a.filter-link--selected:not([href]):hover,
a.filter-link--selected[aria-disabled="true"]:hover {
background-color: #e1e8fd;
}
/* stylelint-disable no-descending-specificity */
button.filter-button:focus:not(:focus-visible),
a.filter-link:focus:not(:focus-visible) {
outline: none;
}
/* stylelint-enable no-descending-specificity */
3 changes: 3 additions & 0 deletions dist/filter-menu-button/ds4/filter-menu-button.css
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,9 @@ button.filter-menu-button__footer:hover {
.filter-menu-button__item[role="menuitemradio"][aria-checked="true"] svg.icon--radio-checked {
display: block;
}
button.filter-menu-button__button:focus:not(:focus-visible) {
outline: none;
}
[dir="rtl"] .filter-menu-button__button-cell .icon--dropdown {
margin-left: 0;
margin-right: 8px;
Expand Down
3 changes: 3 additions & 0 deletions dist/filter-menu-button/ds6/filter-menu-button.css
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,9 @@ button.filter-menu-button__footer:hover {
.filter-menu-button__item[role="menuitemradio"][aria-checked="true"] svg.icon--radio-checked {
display: block;
}
button.filter-menu-button__button:focus:not(:focus-visible) {
outline: none;
}
[dir="rtl"] .filter-menu-button__button-cell .icon--dropdown {
margin-left: 0;
margin-right: 8px;
Expand Down
4 changes: 4 additions & 0 deletions dist/icon-button/ds4/icon-button.css
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ a.icon-link:hover > svg {
fill: #333;
fill: var(--icon-button-icon-hover-foreground-color, #333);
}
button.icon-btn:not(:focus-visible),
a.icon-link:not(:focus-visible) {
outline: none;
}
a.icon-link:visited > svg {
fill: #555;
fill: var(--icon-button-icon-foreground-color, #555);
Expand Down
4 changes: 4 additions & 0 deletions dist/icon-button/ds6/icon-button.css
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ a.icon-link:hover > svg {
fill: #3665f3;
fill: var(--icon-button-icon-hover-foreground-color, #3665f3);
}
button.icon-btn:not(:focus-visible),
a.icon-link:not(:focus-visible) {
outline: none;
}
a.icon-link:visited > svg {
fill: #111820;
fill: var(--icon-button-icon-foreground-color, #111820);
Expand Down
3 changes: 3 additions & 0 deletions dist/listbox-button/ds4/listbox-button.css
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,6 @@ span.listbox-button__value {
-webkit-box-flex: 1;
flex: 1 0 auto;
}
.listbox-button__options:focus:not(:focus-visible) {
outline: none;
}
3 changes: 3 additions & 0 deletions dist/listbox-button/ds6/listbox-button.css
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,6 @@ span.listbox-button__value {
-webkit-box-flex: 1;
flex: 1 0 auto;
}
.listbox-button__options:focus:not(:focus-visible) {
outline: none;
}
3 changes: 3 additions & 0 deletions dist/listbox/ds4/listbox.css
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,6 @@ div.listbox__option[role="option"]:active svg.icon {
color: #ccc;
color: var(--dropdown-item-active-status-color, #ccc);
}
.listbox__options:focus:not(:focus-visible) {
outline: none;
}
3 changes: 3 additions & 0 deletions dist/listbox/ds6/listbox.css
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,6 @@ div.listbox__option[role="option"]:active svg.icon {
color: #fff;
color: var(--dropdown-item-active-status-color, #fff);
}
.listbox__options:focus:not(:focus-visible) {
outline: none;
}
3 changes: 3 additions & 0 deletions dist/menu-button/ds4/menu-button.css
Original file line number Diff line number Diff line change
Expand Up @@ -265,3 +265,6 @@ hr.menu-button__separator {
border-width: 1px;
margin: 0;
}
div.menu-button__item[role^="menuitem"]:focus:not(:focus-visible) {
outline: none;
}
3 changes: 3 additions & 0 deletions dist/menu-button/ds6/menu-button.css
Original file line number Diff line number Diff line change
Expand Up @@ -274,3 +274,6 @@ hr.menu-button__separator {
border-width: 1px;
margin: 0;
}
div.menu-button__item[role^="menuitem"]:focus:not(:focus-visible) {
outline: none;
}
3 changes: 3 additions & 0 deletions dist/menu/ds4/menu.css
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,6 @@ hr.menu__separator {
border-style: solid;
border-width: 1px;
}
div.menu__item[role^="menuitem"]:focus:not(:focus-visible) {
outline: none;
}
3 changes: 3 additions & 0 deletions dist/menu/ds6/menu.css
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,6 @@ hr.menu__separator {
border-style: solid;
border-width: 1px;
}
div.menu__item[role^="menuitem"]:focus:not(:focus-visible) {
outline: none;
}
5 changes: 5 additions & 0 deletions dist/mixins/button/base/button-mixins.less
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@

height: 40px;
}

// https://developer.paciellogroup.com/blog/2018/03/focus-visible-and-backwards-compatibility/
&:focus:not(:focus-visible) {
outline: none;
}
}

.btn-icon-base() {
Expand Down
5 changes: 5 additions & 0 deletions dist/mixins/carousel/base/carousel-mixins.less
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@
.customColorProperty(carousel-paddle-foreground-color);
}

// https://developer.paciellogroup.com/blog/2018/03/focus-visible-and-backwards-compatibility/
&:focus:not(:focus-visible) {
outline: none;
}

// progressive enhancement for browsers with support
// :focus-within and :hover cannot be combined as
// IE/Edge will discard the entire rule
Expand Down
4 changes: 4 additions & 0 deletions dist/pagination/ds4/pagination.css
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ nav.pagination--fluid ol.pagination__items li {
-webkit-box-flex: 1;
flex: 1 0 48px;
}
a.pagination__item:focus:not(:focus-visible),
button.pagination__item:focus:not(:focus-visible) {
outline: none;
}
@media (min-width: 601px) {
nav.pagination {
margin: 16px 0;
Expand Down
4 changes: 4 additions & 0 deletions dist/pagination/ds6/pagination.css
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ nav.pagination--fluid ol.pagination__items li {
-webkit-box-flex: 1;
flex: 1 0 48px;
}
a.pagination__item:focus:not(:focus-visible),
button.pagination__item:focus:not(:focus-visible) {
outline: none;
}
@media (min-width: 601px) {
nav.pagination {
margin: 16px 0;
Expand Down
10 changes: 7 additions & 3 deletions dist/radio/ds4/radio.css
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,16 @@ input.radio__control[type="radio"]:checked + span.radio__icon svg.radio__checked
input.radio__control[type="radio"]:checked + span.radio__icon svg.radio__unchecked {
display: none;
}
input.radio__control[type="radio"]:focus + span.radio__icon {
outline: 1px dotted #767676;
}
input.radio__control[type="radio"][disabled] + span.radio__icon {
opacity: 1;
}
input.radio__control[type="radio"][disabled] + span.radio__icon svg {
fill: #ccc;
}
input.radio__control[type="radio"]:focus + span.radio__icon {
outline: 1px auto #767676;
outline-offset: 2px;
}
input.radio__control[type="radio"]:focus:not(:focus-visible) + span.radio__icon {
outline: none;
}
10 changes: 7 additions & 3 deletions dist/radio/ds6/radio.css
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,16 @@ input.radio__control[type="radio"]:checked + span.radio__icon svg.radio__checked
input.radio__control[type="radio"]:checked + span.radio__icon svg.radio__unchecked {
display: none;
}
input.radio__control[type="radio"]:focus + span.radio__icon {
outline: 1px dotted #767676;
}
input.radio__control[type="radio"][disabled] + span.radio__icon {
opacity: 1;
}
input.radio__control[type="radio"][disabled] + span.radio__icon svg {
fill: #c7c7c7;
}
input.radio__control[type="radio"]:focus + span.radio__icon {
outline: 1px auto #767676;
outline-offset: 2px;
}
input.radio__control[type="radio"]:focus:not(:focus-visible) + span.radio__icon {
outline: none;
}
Loading

0 comments on commit 465b7ae

Please sign in to comment.