diff --git a/src/components/Glossary/GlossaryTooltip/index.tsx b/src/components/Glossary/GlossaryTooltip/index.tsx index 708fa72bd2b..abe9d22f6f4 100644 --- a/src/components/Glossary/GlossaryTooltip/index.tsx +++ b/src/components/Glossary/GlossaryTooltip/index.tsx @@ -26,7 +26,7 @@ const GlossaryTooltip = ({ children, termKey }: GlossaryTooltipProps) => { options={{ ns: "glossary-tooltip" }} /> } - onOpen={() => { + onBeforeOpen={() => { trackCustomEvent({ eventCategory: "Glossary Tooltip", eventAction: cleanPath(asPath), diff --git a/src/components/Tooltip/index.tsx b/src/components/Tooltip/index.tsx index a7abb3bb6ca..2dcdfb0399a 100644 --- a/src/components/Tooltip/index.tsx +++ b/src/components/Tooltip/index.tsx @@ -14,9 +14,15 @@ import { isMobile } from "@/lib/utils/isMobile" export interface IProps extends PopoverProps { content: ReactNode children?: ReactNode + onBeforeOpen?: () => void } -const Tooltip: React.FC = ({ content, children, ...rest }) => { +const Tooltip: React.FC = ({ + content, + children, + onBeforeOpen, + ...rest +}) => { const { isOpen, onOpen, onClose } = useDisclosure() // Close the popover when the user scrolls. @@ -45,10 +51,15 @@ const Tooltip: React.FC = ({ content, children, ...rest }) => { } }, [isOpen, onClose]) + const handleOpen = () => { + onBeforeOpen?.() + onOpen() + } + return (