Skip to content

Commit 20edea0

Browse files
committed
fix(cdk-experimental/tabs): add default aria-labelledby to tab panel
1 parent 06d7384 commit 20edea0

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
@@ -234,6 +234,12 @@ describe('CdkTabs', () => {
234234
expect(tabPanelElements[2].getAttribute('tabindex')).toBe('-1');
235235
});
236236

237+
it('should have aria-labelledby pointing to its tab id', () => {
238+
expect(tabPanelElements[0].getAttribute('aria-labelledby')).toBe(tabElements[0].id);
239+
expect(tabPanelElements[1].getAttribute('aria-labelledby')).toBe(tabElements[1].id);
240+
expect(tabPanelElements[2].getAttribute('aria-labelledby')).toBe(tabElements[2].id);
241+
});
242+
237243
it('should have inert attribute when hidden and not when visible', () => {
238244
updateTabs({selectedTab: 'tab1'});
239245
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
'[attr.id]': 'pattern.id()',
293293
'[attr.tabindex]': 'pattern.tabindex()',
294294
'[attr.inert]': 'pattern.hidden() ? true : null',
295+
'[attr.aria-labelledby]': 'tab()?.id()',
295296
},
296297
hostDirectives: [
297298
{

0 commit comments

Comments
 (0)