Skip to content

Commit

Permalink
Change prop to initial tab and remove extra if
Browse files Browse the repository at this point in the history
  • Loading branch information
camilovegag committed Aug 5, 2024
1 parent d5cae6e commit 22f0f2c
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions packages/berlin/src/components/tabs/TabsHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@ import { Tab } from './TabsHeader.styled';

type TabsHeaderProps = {
tabNames: string[];
activeTab: string;
initialTab: string | null;
className?: string;
onTabChange?: (tab: string) => void;
};

export function TabsHeader({ tabNames, activeTab, className, onTabChange }: TabsHeaderProps) {
export function TabsHeader({ tabNames, initialTab, className, onTabChange }: TabsHeaderProps) {
const handleTabClick = (tab: string) => {
if (activeTab !== tab) {
if (onTabChange) {
onTabChange(tab);
}
if (onTabChange && initialTab !== tab) {
onTabChange(tab);
}
};

Expand All @@ -23,7 +21,7 @@ export function TabsHeader({ tabNames, activeTab, className, onTabChange }: Tabs
{tabNames.map((tabName, index) => (
<Fragment key={tabName}>
<Tab
className={activeTab === tabName ? 'active' : ''}
className={initialTab === tabName ? 'active' : ''}
onClick={() => handleTabClick(tabName)}
>
{tabName}
Expand Down

0 comments on commit 22f0f2c

Please sign in to comment.