Skip to content

Commit

Permalink
Select first tab by default if none found
Browse files Browse the repository at this point in the history
  • Loading branch information
icaraps committed Sep 25, 2020
1 parent 92468ce commit ad4a338
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,14 @@ const GlobalHeader = ({ globalNav, versions, pages, docs, location }) => {
const pathWithRootFix = rootFix(location.pathname);
const pagesWithRootFix = rootFixPages(pages);

return pagesWithRootFix.indexOf(findSelectedTopPage(pathWithRootFix, pagesWithRootFix));
let selectedTabIndex = pagesWithRootFix.indexOf(findSelectedTopPage(pathWithRootFix, pagesWithRootFix));

// Assume first tab is selected
if (selectedTabIndex === -1) {
selectedTabIndex = 0;
}

return selectedTabIndex;
};

const positionSelectedTabIndicator = () => {
Expand Down

0 comments on commit ad4a338

Please sign in to comment.