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
feat(form-field): expose label content element id for custom controls #18528
feat(form-field): expose label content element id for custom controls #18528
Conversation
9c84902
to
0d4326f
Compare
c5fa00e
to
e3101ce
Compare
@@ -23,7 +23,7 @@ class MyTel { | |||
@Component({ | |||
selector: 'example-tel-input', | |||
template: ` | |||
<div [formGroup]="parts"> | |||
<div role="group" [formGroup]="parts"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI: This is the recommended pattern for grouping multiple inputs: https://www.w3.org/TR/WCAG20-TECHS/ARIA17.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@crisbeto do we have this on date-range-input
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@mmalerba Addressed your feedback. Thanks! |
e3101ce
to
307f446
Compare
307f446
to
db1fafe
Compare
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.
Improves the accessibility for the control that is built as part of the custom form-field control guide.
db1fafe
to
83d363e
Compare
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
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, theappropriate 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.
Note: If we decide to go with that change, the target is usually
minor
, but it might be worth checking if we could get it intomaster
earlier for our MDC form-field changes.