Skip to content

Commit

Permalink
chore: optimize condition flow in Button (#14469)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbrugger authored Aug 24, 2023
1 parent eb3b542 commit d936b98
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions packages/react/src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,24 +221,24 @@ const Button = React.forwardRef(function Button<T extends React.ElementType>(
otherProps = anchorProps;
}

const Button = React.createElement(
component,
{
onMouseEnter,
onMouseLeave,
onFocus,
onBlur,
onClick,
...rest,
...commonProps,
...otherProps,
},
assistiveText,
children,
buttonImage
);

if (hasIconOnly) {
if (!hasIconOnly) {
return React.createElement(
component,
{
onMouseEnter,
onMouseLeave,
onFocus,
onBlur,
onClick,
...rest,
...commonProps,
...otherProps,
},
assistiveText,
children,
buttonImage
);
} else {
let align: PopoverAlignment | undefined = undefined;

if (tooltipPosition === 'top' || tooltipPosition === 'bottom') {
Expand Down Expand Up @@ -276,7 +276,6 @@ const Button = React.forwardRef(function Button<T extends React.ElementType>(
</IconButton>
);
}
return Button;
});

Button.displayName = 'Button';
Expand Down

0 comments on commit d936b98

Please sign in to comment.