Skip to content

Commit

Permalink
fix(button): only use tooltipAlignment if button hasIconOnly (#16169)
Browse files Browse the repository at this point in the history
Co-authored-by: Alison Joseph <[email protected]>
  • Loading branch information
tay1orjones and alisonjoseph authored Apr 16, 2024
1 parent 0326f87 commit b82d843
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/react/src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ const Button = React.forwardRef(function Button<T extends React.ElementType>(
const iconOnlyImage = !ButtonImageElement ? null : <ButtonImageElement />;

if (!isIconOnlyButton(hasIconOnly, kind)) {
return <ButtonBase ref={ref} {...props} />;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { tooltipAlignment, ...propsWithoutTooltipAlignment } = props;
return <ButtonBase ref={ref} {...propsWithoutTooltipAlignment} />;
} else {
let align: PopoverAlignment | undefined = undefined;

Expand Down
5 changes: 5 additions & 0 deletions packages/react/src/components/Button/__tests__/Button-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ describe('Button', () => {
);
});

it('should not error on tooltipAlignment even when hasIconOnly=false', () => {
render(<Button tooltipAlignment="start" />);
expect(screen.getByRole('button')).toBeInTheDocument();
});

it.each([
['primary', 'cds--btn'],
['secondary', 'cds--btn--secondary'],
Expand Down

0 comments on commit b82d843

Please sign in to comment.