Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Tooltip overwritten prop #12594

Merged
merged 2 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/Glossary/GlossaryTooltip/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const GlossaryTooltip = ({ children, termKey }: GlossaryTooltipProps) => {
options={{ ns: "glossary-tooltip" }}
/>
}
onOpen={() => {
onBeforeOpen={() => {
trackCustomEvent({
eventCategory: "Glossary Tooltip",
eventAction: cleanPath(asPath),
Expand Down
15 changes: 13 additions & 2 deletions src/components/Tooltip/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<IProps> = ({ content, children, ...rest }) => {
const Tooltip: React.FC<IProps> = ({
content,
children,
onBeforeOpen,
...rest
}) => {
const { isOpen, onOpen, onClose } = useDisclosure()

// Close the popover when the user scrolls.
Expand Down Expand Up @@ -45,10 +51,15 @@ const Tooltip: React.FC<IProps> = ({ content, children, ...rest }) => {
}
}, [isOpen, onClose])

const handleOpen = () => {
onBeforeOpen?.()
onOpen()
}

return (
<Popover
isOpen={isOpen}
onOpen={onOpen}
onOpen={handleOpen}
onClose={onClose}
placement="top"
trigger={isMobile() ? "click" : "hover"}
Expand Down
Loading