Skip to content

Commit 088551e

Browse files
committed
allow the tooltip to display if the button is disabled
1 parent e91e37d commit 088551e

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

apps/webapp/app/components/primitives/Buttons.tsx

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ export const Button = forwardRef<HTMLButtonElement, ButtonPropsType>(
341341
disabled: isDisabled || !props.shortcut,
342342
});
343343

344-
return (
344+
const buttonElement = (
345345
<button
346346
className={cn("group/button outline-none focus-custom", props.fullWidth ? "w-full" : "")}
347347
type={type}
@@ -353,9 +353,30 @@ export const Button = forwardRef<HTMLButtonElement, ButtonPropsType>(
353353
form={props.form}
354354
autoFocus={autoFocus}
355355
>
356-
<ButtonContent {...props} />
356+
<ButtonContent {...props} tooltip={undefined} />
357357
</button>
358358
);
359+
360+
if (props.tooltip) {
361+
return (
362+
<TooltipProvider>
363+
<Tooltip>
364+
<TooltipTrigger asChild>
365+
<span className={isDisabled ? "cursor-default" : undefined}>
366+
{buttonElement}
367+
</span>
368+
</TooltipTrigger>
369+
<TooltipContent className="flex items-center gap-3 py-1.5 pl-2.5 pr-3 text-xs text-text-bright">
370+
{props.tooltip} {props.shortcut && !props.hideShortcutKey && (
371+
<ShortcutKey shortcut={props.shortcut} variant="medium" className="ml-1" />
372+
)}
373+
</TooltipContent>
374+
</Tooltip>
375+
</TooltipProvider>
376+
);
377+
}
378+
379+
return buttonElement;
359380
}
360381
);
361382

0 commit comments

Comments
 (0)