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

Fix: aria-label class not properly hidden (fixes #606) #611

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 2 commits
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
37 changes: 16 additions & 21 deletions less/core/accessibility.less
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,28 @@
.component { position: relative; }
.block { position: relative; }

Copy link
Contributor

@kirsty-hames kirsty-hames Jan 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the bootstrap example, is it worth adding a comment to instruct developers on its usage.

// Use to hide content visually while keeping it accessible to assistive technologies

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

// jquery.a11y start
// Invisible aria-labels
// --------------------------------------------------
.aria-label {
.aria-label, .visually-hidden {
display: block;
position: absolute !important;
&.relative {
position: relative !important;
}
left: 0 !important;
width: auto !important;
height: auto !important;
overflow: auto !important;
color: rgba(0,0,0,0) !important;
background: rgba(0,0,0,0) !important;
font-size: 1px !important;
width: 1px !important;
height: 1px !important;
padding: 0 !important;
margin: 0 !important;
line-height: normal !important;
z-index: 1;
margin: -1px !important;
overflow: hidden !important;
clip: rect(0, 0, 0, 0) !important;
white-space: nowrap !important;
border: 0 !important;
pointer-events: none;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the bootstrap example, is it worth adding a comment to instruct developers on its usage.

// Use to only display content when it's focused

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

// Force aria-labels to hide on hidden
// --------------------------------------------------
.aria-label.aria-hidden {
display: none !important;
.aria-label-focusable, .visually-hidden-focusable {
&:not(:focus):not(:focus-within) {
.visually-hidden
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.visually-hidden includes pointer-events: none; which we probably want to exclude if we intend to use this for clickable buttons e.g. "skip navigation". In which case we could utilise a mixin here. Please see suggestion below.

.visually-hidden() {
  display: block;
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.aria-label {
  .visually-hidden();
  pointer-events: none;
}

.aria-label-focusable, .visually-hidden-focusable {
 &:not(:focus):not(:focus-within) {
    .visually-hidden;
  }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}
}

// jquery.a11y start

// Hidden focus guard
// --------------------------------------------------
.a11y-focusguard {
Expand Down