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/datepicker): add aria labels to <input/>s for Start/End Date
Give `matDateStart` aria label of "Start Date" and give `matDateEnd`
a label of "End Date" by wrapping in a `<label>` element. Apply the aria
label of the form field to the `<mat-date-range-input>` component, which
has role of group. Previously the placeholder was used to communicate
which of the inputs was the start date and which was the end date.
Only affects the DOM structure and a11y tree. Does not change the visual appearance.
Consider the [Basic date range picker
example](https://material.angular.io/components/datepicker/overview#date-range-picker-overview):
```
<mat-form-field appearance="fill">
<mat-label>Enter a date range</mat-label>
<mat-date-range-input [rangePicker]="picker">
<input matStartDate placeholder="Start date">
<input matEndDate placeholder="End date">
</mat-date-range-input>
...
</mat-form-field>
```
Previously, it would produce an accessibility tree that looks something
like this.
```
group "Enter a date range"
LabelText
StaticText "Enter a date range"
textbox "Enter a date range"
Textbox "End date"
```
Problems with this approach.
1. Screen reader does not announce "Start Date" right away or not at
2. "Start date"/"End date" come from the placeholder put a label would
be more appropriate.
With this commit applied, accessibility is consistent between both
inputs, and it is easier to tell which of the two is the start and which
is the end.
```
group "Enter a date range"
LabelText
textbox "Start Date"
LabelText
textbox "End Date"
```
Fixes: #23445
0 commit comments