Skip to content

Commit 86be28e

Browse files
Jessica Xujesscxu
Jessica Xu
andauthored
feat(material/radio): Avoid nested divs in labels by changing to span instead. (#20986)
Co-authored-by: Jessica Xu <[email protected]>
1 parent ae061d7 commit 86be28e

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

src/material/radio/radio.html

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
<!-- TODO(mtlin): Evaluate trade-offs of using native radio vs. cost of additional bindings. -->
33
<label [attr.for]="inputId" class="mat-radio-label" #label>
44
<!-- The actual 'radio' part of the control. -->
5-
<div class="mat-radio-container">
6-
<div class="mat-radio-outer-circle"></div>
7-
<div class="mat-radio-inner-circle"></div>
5+
<span class="mat-radio-container">
6+
<span class="mat-radio-outer-circle"></span>
7+
<span class="mat-radio-inner-circle"></span>
88
<input #input class="mat-radio-input cdk-visually-hidden" type="radio"
99
[id]="inputId"
1010
[checked]="checked"
@@ -21,21 +21,21 @@
2121

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

31-
<div class="mat-ripple-element mat-radio-persistent-ripple"></div>
32-
</div>
33-
</div>
31+
<span class="mat-ripple-element mat-radio-persistent-ripple"></span>
32+
</span>
33+
</span>
3434

3535
<!-- The label content for radio control. -->
36-
<div class="mat-radio-label-content" [class.mat-radio-label-before]="labelPosition == 'before'">
36+
<span class="mat-radio-label-content" [class.mat-radio-label-before]="labelPosition == 'before'">
3737
<!-- Add an invisible span so JAWS can read the label -->
3838
<span style="display:none">&nbsp;</span>
3939
<ng-content></ng-content>
40-
</div>
40+
</span>
4141
</label>

src/material/radio/radio.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ $mat-radio-ripple-radius: 20px;
4646
// The outer circle for the radio, always present.
4747
.mat-radio-outer-circle {
4848
box-sizing: border-box;
49+
display: block;
4950
height: $mat-radio-size;
5051
left: 0;
5152
position: absolute;
@@ -67,6 +68,7 @@ $mat-radio-ripple-radius: 20px;
6768
.mat-radio-inner-circle {
6869
border-radius: 50%;
6970
box-sizing: border-box;
71+
display: block;
7072
height: $mat-radio-size;
7173
left: 0;
7274
position: absolute;

0 commit comments

Comments
 (0)