Fix tooltips (#10154)

* use portal for tooltips

* Fix tooltips for desktop and mobile nav bars

---------

Co-authored-by: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com>
This commit is contained in:
Nicolas Mowen 2024-02-29 17:59:26 -07:00 committed by GitHub
parent e7f8bca2c3
commit dcc0886305
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -6,6 +6,8 @@ import {
TooltipContent,
TooltipTrigger,
} from "@/components/ui/tooltip";
import { useState } from "react";
import { isDesktop } from "react-device-detect";
const variants = {
primary: {
@ -39,9 +41,11 @@ export default function NavItem({
}: NavItemProps) {
const shouldRender = dev ? ENV !== "production" : true;
const [showTooltip, setShowTooltip] = useState(false);
return (
shouldRender && (
<Tooltip>
<Tooltip open={isDesktop && showTooltip}>
<NavLink
to={url}
onClick={onClick}
@ -50,6 +54,8 @@ export default function NavItem({
variants[variant][isActive ? "active" : "inactive"]
}`
}
onMouseEnter={() => (isDesktop ? setShowTooltip(true) : null)}
onMouseLeave={() => (isDesktop ? setShowTooltip(false) : null)}
>
<TooltipTrigger>
<Icon className="size-5 md:m-[6px]" />