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
Show file tree
Hide file tree
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
Prev Previous commit
Improve mobile checkbox/switch accessibility
  • Loading branch information
davwheat committed Aug 15, 2021
commit 9192fe2518fb86b351a6e8664bd5b456d800d38f
4 changes: 3 additions & 1 deletion js/src/common/components/Checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ export default class Checkbox extends Component {
return (
<label className={className}>
<input type="checkbox" checked={this.attrs.state} disabled={this.attrs.disabled} onchange={withAttr('checked', this.onchange.bind(this))} />
<div className="Checkbox-display">{this.getDisplay()}</div>
<div className="Checkbox-display" aria-hidden="true">
{this.getDisplay()}
</div>
{vnode.children}
</label>
);
Expand Down
29 changes: 26 additions & 3 deletions less/common/Checkbox.less
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,42 @@
display: block;
cursor: pointer;
margin: 0;
position: relative;

input[type="checkbox"] {
SychO9 marked this conversation as resolved.
Show resolved Hide resolved
.visually-hidden();
position: absolute;
z-index: 1;

opacity: 0;

top: 0;
bottom: 0;
left: 0;
right: 0;

width: 100%;
height: 100%;

cursor: pointer;

.add-keyboard-focus-ring-nearby("+ .Checkbox-display");
}
}
.Checkbox--switch {
padding-left: 65px;
@left-pad: 65px;

padding-left: @left-pad;
margin: 5px 0;

input[type="checkbox"] {
top: -4px;
width: 50px;
height: 28px;
}

.Checkbox-display {
float: left;
margin-left: -65px;
margin-left: -@left-pad;
margin-top: -4px;
}
}
Expand Down