Skip to content

Commit

Permalink
Don't focus the current tab on init
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarotero authored Feb 14, 2024
1 parent 87d4b4a commit 232d07d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default class Tab extends HTMLElement {
);

if (!setByHash(this, document.location.hash)) {
setTab(this, this.tab, false);
setTab(this, this.tab, false, false);
}
}

Expand Down Expand Up @@ -83,7 +83,7 @@ function moveIndex(el, increment, changeHistory = true) {
}
}

function setTab(el, tab, changeHistory = true) {
function setTab(el, tab, changeHistory = true, autofocus = true) {
const oldTab = el.tab;

if (oldTab) {
Expand All @@ -95,7 +95,9 @@ function setTab(el, tab, changeHistory = true) {
return;
}

tab.focus();
if (autofocus) {
tab.focus();
}
tab.removeAttribute("tabindex");
tab.setAttribute("aria-selected", "true");

Expand Down

0 comments on commit 232d07d

Please sign in to comment.