Skip to content

Commit

Permalink
@next Tabs: expose disabledScrollToTab prop
Browse files Browse the repository at this point in the history
  • Loading branch information
music1353 committed Sep 19, 2024
1 parent c2ba5e5 commit 0566f32
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/@next/Tabs/Tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export type TabProps = {
id?: string;
selected?: boolean;
disabled?: boolean;
disabledScrollToTab?: boolean;
onSelect: () => void;
};

Expand All @@ -15,12 +16,13 @@ export const Tab = ({
id,
selected,
disabled = false,
disabledScrollToTab = false,
onSelect,
}: TabProps) => {
const tabRef = useRef(null);

const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
if (disabled) return;
if (disabled || disabledScrollToTab) return;

event.preventDefault();
tabRef.current.scrollIntoView({ behavior: 'smooth' });
Expand Down
3 changes: 3 additions & 0 deletions src/@next/Tabs/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export type TabsProps = {
selected?: number;
children?: React.ReactNode;
fitted?: boolean;
disabledScrollToTab?: boolean;
onSelected?: (index: number) => void;
};

Expand All @@ -38,6 +39,7 @@ export const Tabs = React.forwardRef<HTMLDivElement, TabsProps>(function Tabs(
selected: selectedIndex = 0,
children,
fitted,
disabledScrollToTab,
onSelected,
}: TabsProps,
ref
Expand Down Expand Up @@ -121,6 +123,7 @@ export const Tabs = React.forwardRef<HTMLDivElement, TabsProps>(function Tabs(
onSelect={() => handleSelectedIndexChanged(index)}
selected={index === selectedTabIndex}
disabled={tab.disabled}
disabledScrollToTab={disabledScrollToTab}
></Tab>
);

Expand Down

0 comments on commit 0566f32

Please sign in to comment.