Skip to content

Commit

Permalink
Fix matching
Browse files Browse the repository at this point in the history
  • Loading branch information
josepjaume committed Nov 15, 2024
1 parent 2cbc069 commit 522da2d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/experimental/Navigation/Tabs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ export const BaseTabs: React.FC<TabsProps> = ({ tabs, secondary = false }) => {
// is active without the index first, and then with the index. Otherwise,
// we would incorrectly match the index tab as active, resulting in two tabs
// being active at the same time.
const sortedTabs = tabs.sort((a, b) => (a.index ? 1 : b.index ? -1 : 0))
const activeTabIndex = sortedTabs.findIndex((tab) => isActive(tab.href))
const sortedTabs = [...tabs].sort((a, b) => (a.index ? 1 : b.index ? -1 : 0))
const activeTab = sortedTabs.find((tab) => isActive(tab.href))

return (
<TabNavigation secondary={secondary}>
{tabs.map(({ label, ...props }, index) => (
<TabNavigationLink
key={index}
active={activeTabIndex === index}
active={activeTab?.href === props.href}
href={props.href}
secondary={secondary}
asChild
Expand Down

0 comments on commit 522da2d

Please sign in to comment.