Skip to content

Commit

Permalink
chore: handle deprecated action callback property correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
Afzal committed Oct 23, 2023
1 parent cdd19eb commit 78f25ae
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/@next/Bar/Bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ export const Bar = React.forwardRef<HTMLDivElement, BarProps>(function Bar(
const buttonSize: 'default' | 'large' =
width <= breakpointWidth ? 'default' : 'large';

function makeButtonProps(buttonAction: ComponentAction) {
const { onClick, action, ...otherProps } = buttonAction;
return {
onClick: onClick || action,
...otherProps,
};
}

return (
<StyledBar data-align={position} ref={ref}>
<StyledBarContainer>
Expand All @@ -79,17 +87,20 @@ export const Bar = React.forwardRef<HTMLDivElement, BarProps>(function Bar(
) : (
<ButtonGroup>
{tertiaryAction && (
<Button {...tertiaryAction} size={buttonSize}>
<Button {...makeButtonProps(tertiaryAction)} size={buttonSize}>
{tertiaryAction.label}
</Button>
)}
{secondaryAction && (
<Button {...secondaryAction} size={buttonSize}>
<Button {...makeButtonProps(secondaryAction)} size={buttonSize}>
{secondaryAction.label}
</Button>
)}
{primaryAction && (
<PrimaryButton {...primaryAction} size={buttonSize}>
<PrimaryButton
{...makeButtonProps(primaryAction)}
size={buttonSize}
>
{primaryAction.label}
</PrimaryButton>
)}
Expand Down

0 comments on commit 78f25ae

Please sign in to comment.