Skip to content

Commit 2db9e23

Browse files
authored
[AX] Color scheme toggle keyboard navigation should follow radio buttons standards (#401)
* [r94221573] fix: color scheme toggle should focus as a radiobutton group * [r94221573] fix: small typo
1 parent 60fd7bf commit 2db9e23

File tree

4 files changed

+29
-17
lines changed

4 files changed

+29
-17
lines changed

src/components/ColorSchemeToggle.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
aria-label="Select a color scheme preference"
1414
class="color-scheme-toggle"
1515
role="radiogroup"
16-
tabindex="0"
1716
>
1817
<label
1918
v-for="option in options"
@@ -85,6 +84,12 @@ input {
8584
appearance: none;
8685
}
8786
87+
label {
88+
@include on-keyboard-focus-within() {
89+
@include focus-outline();
90+
}
91+
}
92+
8893
.text {
8994
border: 1px solid transparent;
9095
border-radius: var(--toggle-border-radius-inner, 2px);

src/components/Filter/FilterInput.vue

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -487,11 +487,9 @@ $input-height: rem(28px);
487487
border-bottom-left-radius: $small-border-radius - 1;
488488
border-bottom-right-radius: $small-border-radius - 1;
489489
490-
.fromkeyboard & {
491-
&:focus {
492-
outline: none;
493-
box-shadow: 0 0 0 5px var(--color-focus-color);
494-
}
490+
@include on-keyboard-focus() {
491+
outline: none;
492+
box-shadow: 0 0 0 5px var(--color-focus-color);
495493
}
496494
}
497495

src/components/Navigator/NavigatorCardItem.vue

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -250,15 +250,13 @@ $nesting-spacing: $card-horizontal-spacing + $card-horizontal-spacing-small;
250250
display: flex;
251251
align-items: center;
252252
253-
.fromkeyboard & {
254-
&:focus-within {
255-
margin: $card-horizontal-spacing-small;
256-
height: $item-height - 10px;
257-
@include focus-outline();
258-
259-
.depth-spacer {
260-
margin-left: -$card-horizontal-spacing-small;
261-
}
253+
@include on-keyboard-focus-within() {
254+
margin: $card-horizontal-spacing-small;
255+
height: $item-height - 10px;
256+
@include focus-outline();
257+
258+
.depth-spacer {
259+
margin-left: -$card-horizontal-spacing-small;
262260
}
263261
}
264262
}

src/styles/core/_helpers.scss

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
line-height: $line-height;
6868
clip-path: unset;
6969
}
70-
}
70+
};
7171

7272
////
7373
/// Apply styling only when focused via the keyboard.
@@ -78,7 +78,18 @@
7878
@content
7979
}
8080
}
81-
}
81+
};
82+
83+
////
84+
/// Apply styling only when focused via the keyboard in an element inside.
85+
////
86+
@mixin on-keyboard-focus-within() {
87+
.fromkeyboard & {
88+
&:focus-within {
89+
@content
90+
}
91+
}
92+
};
8293

8394
////
8495
/// Replaces the outline effect when an element is in focus, with a box shadow effect.

0 commit comments

Comments
 (0)