Skip to content

Commit 85ce566

Browse files
committed
fix(material/timepicker): adds aria-labelledby to timepicker toggle
Updates Angular Component Timepicker so the timepicker toggle uses the aria-labelledby value for the timepicker toggle button to make it more accessible. Fixes b/380308482
1 parent 035c89e commit 85ce566

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

src/dev-app/timepicker/timepicker-demo.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ <h2>Basic timepicker</h2>
1111
[matTimepickerMax]="maxControl.value"
1212
[formControl]="control">
1313
<mat-timepicker [interval]="intervalControl.value" #basicPicker/>
14-
<mat-timepicker-toggle [for]="basicPicker" matSuffix/>
14+
<mat-timepicker-toggle [for]="basicPicker" aria-labelledby="mat-mdc-form-field-label-0" matSuffix/>
1515
</mat-form-field>
1616

1717
<p>Value: {{control.value}}</p>

src/material/timepicker/timepicker-toggle.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
type="button"
44
aria-haspopup="listbox"
55
[attr.aria-label]="ariaLabel()"
6+
[attr.aria-labelledby]="ariaLabelledby()"
67
[attr.aria-expanded]="timepicker().isOpen()"
78
[attr.tabindex]="_isDisabled() ? -1 : tabIndex()"
89
[disabled]="_isDisabled()"

src/material/timepicker/timepicker-toggle.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ export class MatTimepickerToggle<D> {
6262
alias: 'aria-label',
6363
});
6464

65+
/** Screen-reader labelled by id for the button. */
66+
readonly ariaLabelledby = input<string | undefined>(undefined, {
67+
alias: 'aria-labelledby',
68+
});
69+
6570
/** Whether the toggle button is disabled. */
6671
readonly disabled: InputSignalWithTransform<boolean, unknown> = input(false, {
6772
transform: booleanAttribute,

0 commit comments

Comments
 (0)