Skip to content

Commit

Permalink
fix(material/datepicker): datepicker doesn't announce newly selected …
Browse files Browse the repository at this point in the history
…range in firefox (#28529)

* fix(material/datepicker): multi-year view changes in datepicker doesn't announce selected year range

Fixes a bug in the Angular Material  component where when the selected year range is
updated by moving foward to the next range or by moving to the previous range the screenreader
announces the original date range rather than the newly selected date range. This because the
 class was removing the new value from the Firefox accessibility tree.

Fixes #28360

* !fixup fix(material/datepicker): multi-year view changes in datepicker doesn't announce selected year range

Adds comment in html file to connect the filed Firefox issue with the workaround.

Fixes #28360
  • Loading branch information
essjay05 committed Mar 5, 2024
1 parent 94306f3 commit c72add6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/material/datepicker/calendar-header.html
@@ -1,5 +1,9 @@
<div class="mat-calendar-header">
<div class="mat-calendar-controls">
<!-- [Firefox Issue: https://bugzilla.mozilla.org/show_bug.cgi?id=1880533]
Relocated label next to related button and made visually hidden via cdk-visually-hidden
to enable label to appear in a11y tree for SR when using Firefox -->
<label [id]="_periodButtonLabelId" class="cdk-visually-hidden">{{periodButtonDescription}}</label>
<button mat-button type="button" class="mat-calendar-period-button"
(click)="currentPeriodClicked()" [attr.aria-label]="periodButtonLabel"
[attr.aria-describedby]="_periodButtonLabelId" aria-live="polite">
Expand All @@ -25,4 +29,3 @@
</button>
</div>
</div>
<label [id]="_periodButtonLabelId" class="mat-calendar-hidden-label">{{periodButtonDescription}}</label>
4 changes: 0 additions & 4 deletions src/material/datepicker/calendar.scss
Expand Up @@ -174,7 +174,3 @@ $_tokens: tokens-mat-datepicker.$prefix, tokens-mat-datepicker.get-token-slots()
content: '';
}

// Label that is not rendered and removed from the accessibility tree.
.mat-calendar-hidden-label {
display: none;
}

0 comments on commit c72add6

Please sign in to comment.