Skip to content

Commit 65d72f6

Browse files
committed
fix(cdk-experimental/tabs): add default aria-labelledby to tab panel
1 parent 25c31fd commit 65d72f6

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/cdk-experimental/tabs/tabs.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,12 @@ describe('CdkTabs', () => {
229229
});
230230
});
231231

232+
it('should have aria-labelledby pointing to its tab id', () => {
233+
expect(tabPanelElements[0].getAttribute('aria-labelledby')).toBe(tabElements[0].id);
234+
expect(tabPanelElements[1].getAttribute('aria-labelledby')).toBe(tabElements[1].id);
235+
expect(tabPanelElements[2].getAttribute('aria-labelledby')).toBe(tabElements[2].id);
236+
});
237+
232238
it('should have inert attribute when hidden and not when visible', () => {
233239
updateTabs({selectedTab: 'tab1'});
234240
expect(tabPanelElements[0].hasAttribute('inert')).toBe(false);

src/cdk-experimental/tabs/tabs.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ export class CdkTab implements HasElement, OnInit, OnDestroy {
292292
'class': 'cdk-tabpanel',
293293
'[attr.id]': 'pattern.id()',
294294
'[attr.inert]': 'pattern.hidden() ? true : null',
295+
'[attr.aria-labelledby]': 'tab()?.id()',
295296
},
296297
hostDirectives: [
297298
{

0 commit comments

Comments
 (0)