Skip to content

Commit 4a2d4ef

Browse files
crisbetojelbourn
authored andcommitted
fix(datepicker): screen reader reading out role twice (#15663)
Currently the markup of the calendar is `div[role="grid"] > table > td[role="gridcell"]`. Because we've got both a `grid` and a `table`, NVDA ends up reading out something like "Dialog, table, table, 31st of March 2019, column X, row Y". These changes set the `table` to be a `presentation` role so that "table" is only read out once.
1 parent 58db9db commit 4a2d4ef

File tree

6 files changed

+18
-3
lines changed

6 files changed

+18
-3
lines changed

src/material/datepicker/month-view.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<table class="mat-calendar-table">
1+
<table class="mat-calendar-table" role="presentation">
22
<thead class="mat-calendar-table-header">
33
<tr><th *ngFor="let day of _weekdays" [attr.aria-label]="day.long">{{day.narrow}}</th></tr>
44
<tr><th class="mat-calendar-table-header-divider" colspan="7" aria-hidden="true"></th></tr>

src/material/datepicker/month-view.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ describe('MatMonthView', () => {
9898
});
9999

100100
describe('a11y', () => {
101+
it('should set the correct role on the internal table node', () => {
102+
const table = monthViewNativeElement.querySelector('table')!;
103+
expect(table.getAttribute('role')).toBe('presentation');
104+
});
105+
101106
describe('calendar body', () => {
102107
let calendarBodyEl: HTMLElement;
103108
let calendarInstance: StandardMonthView;

src/material/datepicker/multi-year-view.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<table class="mat-calendar-table">
1+
<table class="mat-calendar-table" role="presentation">
22
<thead class="mat-calendar-table-header">
33
<tr><th class="mat-calendar-table-header-divider" colspan="4"></th></tr>
44
</thead>

src/material/datepicker/multi-year-view.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ describe('MatMultiYearView', () => {
100100
});
101101

102102
describe('a11y', () => {
103+
it('should set the correct role on the internal table node', () => {
104+
const table = multiYearViewNativeElement.querySelector('table')!;
105+
expect(table.getAttribute('role')).toBe('presentation');
106+
});
107+
103108
describe('calendar body', () => {
104109
let calendarBodyEl: HTMLElement;
105110
let calendarInstance: StandardMultiYearView;

src/material/datepicker/year-view.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<table class="mat-calendar-table">
1+
<table class="mat-calendar-table" role="presentation">
22
<thead class="mat-calendar-table-header">
33
<tr><th class="mat-calendar-table-header-divider" colspan="4"></th></tr>
44
</thead>

src/material/datepicker/year-view.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ describe('MatYearView', () => {
115115
});
116116

117117
describe('a11y', () => {
118+
it('should set the correct role on the internal table node', () => {
119+
const table = yearViewNativeElement.querySelector('table')!;
120+
expect(table.getAttribute('role')).toBe('presentation');
121+
});
122+
118123
describe('calendar body', () => {
119124
let calendarBodyEl: HTMLElement;
120125
let calendarInstance: StandardYearView;

0 commit comments

Comments
 (0)