Skip to content

Commit abc4d2e

Browse files
authored
Update tab.js (#242)
1 parent 7e72465 commit abc4d2e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/js/tab/tab.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,11 @@ class TabsElement extends HTMLElement {
146146

147147
// Create tab button
148148
const tabButton = document.createElement('button');
149-
tabButton.setAttribute('aria-expanded', !!tab.hasAttribute('active'));
149+
tabButton.setAttribute('aria-selected', !!tab.hasAttribute('active'));
150150
tabButton.setAttribute('aria-controls', tab.id);
151151
tabButton.setAttribute('role', 'tab');
152152
tabButton.setAttribute('type', 'button');
153+
tabButton.setAttribute('tabindex', 0);
153154
tabButton.innerHTML = `${tab.getAttribute('name')}`;
154155
this.tabButtonContainer.appendChild(tabButton);
155156

@@ -244,7 +245,8 @@ class TabsElement extends HTMLElement {
244245
deactivateTabs() {
245246
this.tabs.map((tabObj) => {
246247
tabObj.accordionButton.removeAttribute('aria-disabled');
247-
tabObj.tabButton.removeAttribute('aria-expanded');
248+
tabObj.tabButton.setAttribute('aria-selected', false);
249+
tabObj.tabButton.setAttribute('tabindex', -1);
248250
tabObj.accordionButton.setAttribute('aria-expanded', false);
249251

250252
if (tabObj.tab.hasAttribute('active')) {
@@ -283,7 +285,7 @@ class TabsElement extends HTMLElement {
283285
// Remove current active
284286
this.deactivateTabs();
285287
// Set new active
286-
currentTrigger.tabButton.setAttribute('aria-expanded', true);
288+
currentTrigger.tabButton.setAttribute('aria-selected', true);
287289
currentTrigger.accordionButton.setAttribute('aria-expanded', true);
288290
currentTrigger.accordionButton.setAttribute('aria-disabled', true);
289291
currentTrigger.tab.setAttribute('active', '');

0 commit comments

Comments
 (0)