Skip to content

fix(cdk-experimental/tabs): add default aria-labelledby to tab panel #31388

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/cdk-experimental/tabs/tabs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,12 @@ describe('CdkTabs', () => {
expect(tabPanelElements[2].getAttribute('tabindex')).toBe('-1');
});

it('should have aria-labelledby pointing to its tab id', () => {
expect(tabPanelElements[0].getAttribute('aria-labelledby')).toBe(tabElements[0].id);
expect(tabPanelElements[1].getAttribute('aria-labelledby')).toBe(tabElements[1].id);
expect(tabPanelElements[2].getAttribute('aria-labelledby')).toBe(tabElements[2].id);
});

it('should have inert attribute when hidden and not when visible', () => {
updateTabs({selectedTab: 'tab1'});
expect(tabPanelElements[0].hasAttribute('inert')).toBe(false);
Expand Down
1 change: 1 addition & 0 deletions src/cdk-experimental/tabs/tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ export class CdkTab implements HasElement, OnInit, OnDestroy {
'[attr.id]': 'pattern.id()',
'[attr.tabindex]': 'pattern.tabindex()',
'[attr.inert]': 'pattern.hidden() ? true : null',
'[attr.aria-labelledby]': 'tab()?.id()',
},
hostDirectives: [
{
Expand Down
Loading