Skip to content

Commit 521de2a

Browse files
feat(material/datepicker): Add aria-current="date" to the current date's cell
1 parent ccf3f46 commit 521de2a

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/material/datepicker/calendar-body.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
[attr.aria-label]="item.ariaLabel"
5050
[attr.aria-disabled]="!item.enabled || null"
5151
[attr.aria-selected]="_isSelected(item.compareValue)"
52+
[attr.aria-current]="todayValue === item.compareValue ? 'date' : null"
5253
(click)="_cellClicked(item, $event)"
5354
[style.width]="_cellWidth"
5455
[style.paddingTop]="_cellPadding"

src/material/datepicker/calendar-body.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ describe('MatCalendarBody', () => {
5555
expect(todayCell.innerHTML.trim()).toBe('3');
5656
});
5757

58+
it('sets aria-current="date" on today', () => {
59+
const todayCell = calendarBodyNativeElement.querySelector(
60+
'[aria-current="date"] .mat-calendar-body-today')!;
61+
expect(todayCell).not.toBeNull();
62+
expect(todayCell.innerHTML.trim()).toBe('3');
63+
});
64+
5865
it('highlights selected', () => {
5966
const selectedCell = calendarBodyNativeElement.querySelector('.mat-calendar-body-selected')!;
6067
expect(selectedCell).not.toBeNull();

0 commit comments

Comments
 (0)