Skip to content

Commit

Permalink
tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
scomea committed Jan 23, 2024
1 parent 633b386 commit 420efc1
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions packages/web-components/fast-foundation/src/tabs/tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,25 +295,19 @@ export class FASTTabs extends FASTElement {
newTabIds.push(tab.id);
});

// Do a second pass to set other default id based attributes if they have not been set.
// Do a second pass to set other default id based attributes.
// This enables a default behavior where tabs and tabpanels are associated based on
// their index in the DOM (ie. first tab associated with first tab panel, etc...)
if (
this.tabpanels.length === this.tabs.length &&
this.customTabOrder === undefined
) {
this.tabpanels.forEach((tabPanel: HTMLElement, index: number) => {
// if a tab-panel does not already have a labbelledby defined
// assign the id of the tab of the same index.
// When using a custom tab order the labelledby attribute is only
// applied when a tab-panel is selected.
tabPanel.setAttribute("aria-labelledby", newTabIds[index]);
});
this.tabs.forEach((tab: HTMLElement, index: number) => {
// if a tab does not already have a controlled panel defined
// assign the id of the panel of the same index.
tab.setAttribute("aria-controls", newTabPanelIds[index]);
});
this.tabpanels.forEach((tabPanel: HTMLElement, index: number) => {
tabPanel.setAttribute("aria-labelledby", newTabIds[index]);
});
}

if (!this.customTabOrder) {
Expand Down

0 comments on commit 420efc1

Please sign in to comment.