You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(material-experimental/mdc-checkbox): remove extra a11y tree node for the <label/>
In the mdc checkbox component, removes the click handler on <label/>
and handles stoping propgation of clicks on the label in the label's
parent. This removes the extra a11y tree node on the label and fixes
TalkBack having an extra navigation stop (#14385).
A11y tree before this commit. It has an un-necessary node, which
coresponds to the `<label>` element.
```
- Generic
- Checkbox, "Field A"
- Textlabel, "Field A"
```
A11y tree with this commit applied
```
- Generic
- Checkbox, "Field A"
```
fixes#14385
Copy file name to clipboardExpand all lines: src/material-experimental/mdc-checkbox/checkbox.ts
+10Lines changed: 10 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -388,4 +388,14 @@ export class MatCheckbox
388
388
nativeCheckbox.nativeElement.indeterminate=value;
389
389
}
390
390
}
391
+
392
+
/**
393
+
* Prevent click events that come from the <label/> element from bubbling. This prevents the click handler on the host from triggering twice when clicking on the <label/> element. After the click event on the <label/> propagates, the browsers dispatches click on the associated <input/>. By prevent bubbling of clicks from the label, we ensure only only click event bubbles when the label is clicked.
0 commit comments