Skip to content

Commit

Permalink
Update: Convert focus to focus-visible (fixes adaptlearning#376 adapt…
Browse files Browse the repository at this point in the history
  • Loading branch information
guywillis authored Dec 7, 2022
1 parent 982e869 commit 7d93d24
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 9 deletions.
2 changes: 1 addition & 1 deletion less/plugins/adapt-contrib-gmcq/gmcq.less
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
}

.no-touch &__label:not(.is-disabled):not(.is-selected):hover &__option,
html:not(.a11y-disable-focusoutline) &__input:focus + &__label &__option {
html:not(.a11y-disable-focusoutline) &__input:focus-visible + &__label &__option {
background-color: @item-color-hover;
color: @item-color-inverted-hover;
.transition(background-color @duration ease-in, color @duration ease-in;);
Expand Down
6 changes: 3 additions & 3 deletions less/plugins/adapt-contrib-matching/dropdown.less
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
color: @item-color-inverted;

.no-touch &:not(.is-disabled):not([aria-expanded="true"]):hover,
html:not(.a11y-disable-focusoutline) &:focus {
html:not(.a11y-disable-focusoutline) &:focus-visible {
background-color: @item-color-hover;
color: @item-color-inverted-hover;
.transition(background-color @duration ease-in, color @duration ease-in;);
Expand Down Expand Up @@ -50,13 +50,13 @@
border-bottom: 1px solid @item-color-hover;
color: @item-color-inverted;

.no-touch &:not(:focus):not([aria-selected="true"]):hover {
.no-touch &:not(:focus-visible):not([aria-selected="true"]):hover {
background-color: @item-color-hover;
color: @item-color-inverted-hover;
.transition(background-color @duration ease-in, color @duration ease-in;);
}

&:focus,
&:focus-visible,
&[aria-selected="true"] {
// This code can be used to style a non-native dropdown as closely
// as possible to the default browser settings
Expand Down
2 changes: 1 addition & 1 deletion less/plugins/adapt-contrib-mcq/mcq.less
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
border-radius: @item-border-radius;

.no-touch &:not(.is-disabled):not(.is-selected):hover,
html:not(.a11y-disable-focusoutline) .mcq-item__input:focus + & {
html:not(.a11y-disable-focusoutline) .mcq-item__input:focus-visible + & {
background-color: @item-color-hover;
color: @item-color-inverted-hover;
.transition(background-color @duration ease-in, color @duration ease-in;);
Expand Down
23 changes: 20 additions & 3 deletions less/plugins/adapt-contrib-narrative/narrative.less
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,41 @@
}
}

// set icon background color to transparent to 'inherit' strapline styling
&__strapline-icon {
background-color: @item-color;
background-color: transparent;
color: @item-color-inverted;
}

.no-touch &__strapline-btn:not(.is-disabled):not(.is-locked):hover,
.no-touch &__strapline-btn:not(.is-disabled):not(.is-locked):hover &__strapline-icon {
background-color: @item-color-hover;
color: @item-color-inverted-hover;
.transition(background-color @duration ease-in, color @duration ease-in;);
}

.no-touch &__strapline-btn:not(.is-disabled):not(.is-locked):hover {
background-color: @item-color-hover;
}

// set icon hover background color to transparent to 'inherit' strapline styling
.no-touch &__strapline-btn:not(.is-disabled):not(.is-locked):hover &__strapline-icon {
background-color: transparent;
}

&__strapline-btn.is-visited,
&__strapline-btn.is-visited &__strapline-icon {
background-color: @visited;
color: @visited-inverted;
}

&__strapline-btn.is-visited {
background-color: @visited;
}

// set icon visited background color to transparent to 'inherit' strapline styling
&__strapline-btn.is-visited &__strapline-icon {
background-color: transparent;
}

&.has-img-zoom &__slider-image-container {
.img-zoom();
}
Expand Down
2 changes: 1 addition & 1 deletion less/plugins/adapt-contrib-slider/slider.less
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@

// Rangeslider focus styles
// --------------------------------------------------
input[type='range']:focus + .rangeslider .rangeslider__handle {
input[type='range']:focus-visible + .rangeslider .rangeslider__handle {
html:not(.a11y-disable-focusoutline) & {
box-shadow: 0 2px 5px fade(@black, 60%);
}
Expand Down

0 comments on commit 7d93d24

Please sign in to comment.