Skip to content

feat(material/radio): Avoid nested divs in labels by changing to span instead. #20986

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

Merged
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
18 changes: 9 additions & 9 deletions src/material/radio/radio.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<!-- TODO(mtlin): Evaluate trade-offs of using native radio vs. cost of additional bindings. -->
<label [attr.for]="inputId" class="mat-radio-label" #label>
<!-- The actual 'radio' part of the control. -->
<div class="mat-radio-container">
<div class="mat-radio-outer-circle"></div>
<div class="mat-radio-inner-circle"></div>
<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"
[id]="inputId"
[checked]="checked"
Expand All @@ -21,21 +21,21 @@

<!-- The ripple comes after the input so that we can target it with a CSS
sibling selector when the input is focused. -->
<div mat-ripple class="mat-radio-ripple mat-focus-indicator"
<span mat-ripple class="mat-radio-ripple mat-focus-indicator"
[matRippleTrigger]="label"
[matRippleDisabled]="_isRippleDisabled()"
[matRippleCentered]="true"
[matRippleRadius]="20"
[matRippleAnimation]="{enterDuration: 150}">

<div class="mat-ripple-element mat-radio-persistent-ripple"></div>
</div>
</div>
<span class="mat-ripple-element mat-radio-persistent-ripple"></span>
</span>
</span>

<!-- The label content for radio control. -->
<div class="mat-radio-label-content" [class.mat-radio-label-before]="labelPosition == 'before'">
<span class="mat-radio-label-content" [class.mat-radio-label-before]="labelPosition == 'before'">
<!-- Add an invisible span so JAWS can read the label -->
<span style="display:none">&nbsp;</span>
<ng-content></ng-content>
</div>
</span>
</label>
2 changes: 2 additions & 0 deletions src/material/radio/radio.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ $mat-radio-ripple-radius: 20px;
// The outer circle for the radio, always present.
.mat-radio-outer-circle {
box-sizing: border-box;
display: block;
height: $mat-radio-size;
left: 0;
position: absolute;
Expand All @@ -67,6 +68,7 @@ $mat-radio-ripple-radius: 20px;
.mat-radio-inner-circle {
border-radius: 50%;
box-sizing: border-box;
display: block;
height: $mat-radio-size;
left: 0;
position: absolute;
Expand Down