Skip to content

Commit 6464b73

Browse files
committed
fix(tabs): only use aria-current on active links
We previously set `aria-current` to either "true" or "false" for each `matTabLink`. This change now only applies the attribute to the active tab, omitting it for inactive tabs. Additionally, instead of setting true, we now set the attribute to "page", which specifically indicates that the item is a link that refers to the current page. Fixes #16557
1 parent 036729d commit 6464b73

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/material/tabs/tab-nav-bar/tab-nav-bar.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ describe('MatTabNavBar', () => {
8080

8181
tabLink1.nativeElement.click();
8282
fixture.detectChanges();
83-
expect(tabLinkElements[0].getAttribute('aria-current')).toEqual('true');
84-
expect(tabLinkElements[1].getAttribute('aria-current')).toEqual('false');
83+
expect(tabLinkElements[0].getAttribute('aria-current')).toEqual('page');
84+
expect(tabLinkElements[1].hasAttribute('aria-current')).toEqual(false);
8585

8686
tabLink2.nativeElement.click();
8787
fixture.detectChanges();
88-
expect(tabLinkElements[0].getAttribute('aria-current')).toEqual('false');
89-
expect(tabLinkElements[1].getAttribute('aria-current')).toEqual('true');
88+
expect(tabLinkElements[0].hasAttribute('aria-current')).toEqual(false);
89+
expect(tabLinkElements[1].getAttribute('aria-current')).toEqual('page');
9090
});
9191

9292
it('should add the disabled class if disabled', () => {

src/material/tabs/tab-nav-bar/tab-nav-bar.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ const _MatTabLinkMixinBase:
168168
inputs: ['disabled', 'disableRipple', 'tabIndex'],
169169
host: {
170170
'class': 'mat-tab-link',
171-
'[attr.aria-current]': 'active',
171+
'[attr.aria-current]': 'active ? "page" : null',
172172
'[attr.aria-disabled]': 'disabled',
173173
'[attr.tabIndex]': 'tabIndex',
174174
'[class.mat-tab-disabled]': 'disabled',

0 commit comments

Comments
 (0)