Skip to content

Commit

Permalink
fix: disable button tooltips with empty content (#730)
Browse files Browse the repository at this point in the history
* fix: disable button tooltips with empty content

* refactor: improve code

Co-authored-by: Daniel Kostro <kostro.d@gmail.com>

* fix: make TooltipProps partial in Button component

---------

Co-authored-by: Daniel Kostro <kostro.d@gmail.com>
  • Loading branch information
hamed-musallam and stropitek committed May 28, 2024
1 parent 1827fe7 commit ebdd792
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/components/button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,28 @@ type BlueprintProps = {
BlueprintAnchorButtonProps[key];
};
export type ButtonProps = BlueprintProps & {
tooltipProps?: Omit<TooltipProps, 'children'>;
tooltipProps?: Partial<Omit<TooltipProps, 'children'>>;
tag?: ReactNode;
tagProps?: Omit<TagProps, 'children'>;
};

export function Button(props: ButtonProps) {
const { tooltipProps, children, tag, tagProps, ...buttonProps } = props;

const { tooltipProps = {}, children, tag, tagProps, ...buttonProps } = props;
const {
fill,
content = '',
disabled = !tooltipProps.content,
...otherToolTipProps
} = tooltipProps;
const InnerButton = buttonProps.disabled
? BlueprintAnchorButton
: BlueprintButton;
return (
<Tooltip
fill={tooltipProps?.fill || buttonProps.fill}
{...tooltipProps}
fill={fill || buttonProps.fill}
disabled={disabled}
content={content}
{...otherToolTipProps}
renderTarget={({ isOpen, ...targetProps }) => (
<div style={{ position: 'relative' }}>
{tag && (
Expand Down

0 comments on commit ebdd792

Please sign in to comment.