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(material/radio): not checked on first click if partially visible #19505

Merged
merged 1 commit into from
Feb 18, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion src/material/radio/radio.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<span class="mat-radio-container">
<span class="mat-radio-outer-circle"></span>
<span class="mat-radio-inner-circle"></span>
<input #input class="mat-radio-input cdk-visually-hidden" type="radio"
<input #input class="mat-radio-input" type="radio"
Copy link
Member Author

Choose a reason for hiding this comment

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

@jelbourn I don't remember why we ended up with cdk-visually-hidden in the first place, but from my testing, screen readers treat it exactly the same as when the input is opacity: 0. Given that we have the same issue in the other input-based components (slide toggle and checkbox), would it make sense to stop using it on native inputs?

Copy link
Member

Choose a reason for hiding this comment

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

AFAIK we can't rely on just opacity: 0. I looked through my notes with Google a11y folks and had this from 2018:

Accessibility tree visibility of elements with `opacity: 0` across screen readers?
- Cannot rely on this.
- Possibly could set to .001
- Probably JAWS also, potentially in IE only

Which I interpret as JAWS treating opacity: 0 as fully hidden.

Copy link
Member Author

Choose a reason for hiding this comment

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

I know that IE used to have some security restrictions if an input[type="file"] has opacity: 0. I wonder whether that's not related to your notes.

[id]="inputId"
[checked]="checked"
[disabled]="disabled"
Expand Down
12 changes: 8 additions & 4 deletions src/material/radio/radio.scss
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,14 @@ $mat-radio-ripple-radius: 20px;
}

.mat-radio-input {
// Move the input in the middle and towards the bottom so
// the native validation messages are aligned correctly.
bottom: 0;
left: 50%;
opacity: 0;
position: absolute;
top: 0;
left: 0;
margin: 0;
width: 100%;
height: 100%;
cursor: inherit;
}

@include cdk-high-contrast(active, off) {
Expand Down