mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-08 20:25:19 +02:00
feat: enhance TooltipIconButton to conditionally disable tooltips
This commit is contained in:
parent
893df1718b
commit
591bd6bb46
2 changed files with 8 additions and 2 deletions
|
|
@ -713,6 +713,7 @@ const ComposerAction: FC<ComposerActionProps> = ({ isBlockedByOtherUser = false
|
|||
<TooltipIconButton
|
||||
tooltip="Manage tools"
|
||||
side="bottom"
|
||||
disableTooltip={toolsPopoverOpen}
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="size-[34px] rounded-full p-1 font-semibold text-xs hover:bg-muted-foreground/15 dark:border-muted-foreground/15 dark:hover:bg-muted-foreground/30"
|
||||
|
|
|
|||
|
|
@ -4,17 +4,22 @@ import { Slottable } from "@radix-ui/react-slot";
|
|||
import { type ComponentPropsWithRef, forwardRef, type ReactNode } from "react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
|
||||
import { useMediaQuery } from "@/hooks/use-media-query";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export type TooltipIconButtonProps = ComponentPropsWithRef<typeof Button> & {
|
||||
tooltip: ReactNode;
|
||||
side?: "top" | "bottom" | "left" | "right";
|
||||
disableTooltip?: boolean;
|
||||
};
|
||||
|
||||
export const TooltipIconButton = forwardRef<HTMLButtonElement, TooltipIconButtonProps>(
|
||||
({ children, tooltip, side = "bottom", className, ...rest }, ref) => {
|
||||
({ children, tooltip, side = "bottom", className, disableTooltip, ...rest }, ref) => {
|
||||
const isTouchDevice = useMediaQuery("(pointer: coarse)");
|
||||
const suppressTooltip = disableTooltip || isTouchDevice;
|
||||
|
||||
return (
|
||||
<Tooltip>
|
||||
<Tooltip open={suppressTooltip ? false : undefined}>
|
||||
<TooltipTrigger asChild>
|
||||
<Button
|
||||
variant="ghost"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue