Skip to content

Commit 66f7efb

Browse files
crisbetoandrewseguin
authored andcommitted
fix(tabs): tab position and amount of tabs not being read out by screen reader (#11694)
Fixes some screenreader/browser combinations not reading out the amount of tabs and the index of the current tab. Fixes #11369.
1 parent 11eb2be commit 66f7efb

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/lib/tabs/tab-group.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
*ngFor="let tab of _tabs; let i = index"
88
[id]="_getTabLabelId(i)"
99
[attr.tabIndex]="_getTabIndex(tab, i)"
10+
[attr.aria-posinset]="i + 1"
11+
[attr.aria-setsize]="_tabs.length"
1012
[attr.aria-controls]="_getTabContentId(i)"
1113
[attr.aria-selected]="selectedIndex == i"
1214
[class.mat-tab-label-active]="selectedIndex == i"

src/lib/tabs/tab-group.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,16 @@ describe('MatTabGroup', () => {
221221

222222
expect(fixture.componentInstance.animationDone).toHaveBeenCalled();
223223
}));
224+
225+
it('should add the proper `aria-setsize` and `aria-posinset`', () => {
226+
fixture.detectChanges();
227+
228+
const labels = Array.from(element.querySelectorAll('.mat-tab-label'));
229+
230+
expect(labels.map(label => label.getAttribute('aria-posinset'))).toEqual(['1', '2', '3']);
231+
expect(labels.every(label => label.getAttribute('aria-setsize') === '3')).toBe(true);
232+
});
233+
224234
});
225235

226236
describe('disable tabs', () => {

0 commit comments

Comments
 (0)