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
feat(form-field): expose label content element id for custom controls (#18528)
* feat(form-field): expose label element id for custom controls
Currently, the form-field always creates a label element as sibling
to projected form-field controls. For native controls, the label is
associated with the controls using the `for` attribute.
This doesn't work for custom controls which might not be based
on native controls. e.g. the `mat-select`. In those cases, the
appropriate aria attributes need to be applied with `aria-labelledby`
that refers to the label content element.
Since this is a common pattern for custom controls that don't use
native controls, we need to expose the element id for the label content.
Currently we already do this for the select, but just prefixed it with
an underscore. This denotes it as private API while there is obviously a
use-case for exposing this publicly. Best example is how the select
_needs_ it.
* docs: improve accessibility for custom form-field control guide
Improves the accessibility for the control that is built as part
of the custom form-field control guide.
Copy file name to clipboardExpand all lines: src/components-examples/material-experimental/mdc-form-field/mdc-form-field-custom-control/example-tel-input-example.html
Copy file name to clipboardExpand all lines: src/components-examples/material-experimental/mdc-form-field/mdc-form-field-custom-control/form-field-custom-control-example.ts
Copy file name to clipboardExpand all lines: src/components-examples/material/form-field/form-field-custom-control/form-field-custom-control-example.ts
+9-8Lines changed: 9 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -3,22 +3,23 @@ import {coerceBooleanProperty} from '@angular/cdk/coercion';
0 commit comments