Skip to content
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

[A11Y] Make checkboxes focusable #3014

Merged
merged 5 commits into from
Aug 16, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add extra feature to a11y focusring mixin
  • Loading branch information
davwheat committed Aug 11, 2021
commit 6a15c52a1ba17919a17cc062017424138f26372d
36 changes: 34 additions & 2 deletions less/common/mixins/accessibility.less
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@
*
* For example...
*
*? button { .addKeyboardFocusRing(":focus-within") }
*? button { .add-keyboard-focus-ring(":focus-within") }
* becomes
*? button:focus-within { <styles> }
*
* AND
*
*? button { .addKeyboardFocusRing(" :focus-within") }
*? button { .add-keyboard-focus-ring(" :focus-within") }
* becomes
*? button :focus-within { <styles> }
*/
Expand All @@ -57,6 +57,38 @@
}
}

/**
* This mixin allows support for a custom element nearby the focused one
* to have a focus style applied to it
*
* For example...
*
*? button { .add-keyboard-focus-ring-nearby("+ .myOtherElement") }
* becomes
*? button:-moz-focusring + .myOtherElement { <styles> }
*? button:focus-within + .myOtherElement { <styles> }
*/
.add-keyboard-focus-ring-nearby(@nearbySelector) {
@realNearbySelector: ~"@{nearbySelector}";

// We need to declare these separately, otherwise
// browsers will ignore `:focus-visible` as they
// don't understand `:-moz-focusring`

// These are the keyboard-only versions of :focus
&:-moz-focusring {
@{realNearbySelector} {
#private.__focus-ring-styles();
}
}

&:focus-visible {
@{realNearbySelector} {
#private.__focus-ring-styles();
}
}
}

/**
* Allows an offset to be supplied for an a11y
* outline.
Expand Down