Skip to content

Commit

Permalink
fix: add check to see if ref is defined
Browse files Browse the repository at this point in the history
  • Loading branch information
allroundexperts committed Oct 23, 2023
1 parent 21cca81 commit 6316669
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/components/Tooltip/PopoverAnchorTooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,19 @@ const defaultProps = {

function PopoverAnchorTooltip({shouldRender, children, ...props}) {
const {isOpen, popover} = useContext(PopoverContext);

const tooltipRef = useRef(null);

const isPopoverRelatedToTooltipOpen = useMemo(() => {
// eslint-disable-next-line
const tooltipNode = tooltipRef.current ? tooltipRef.current._childNode : null;
if (isOpen && popover && popover.anchorRef.current && tooltipNode && (tooltipNode.contains(popover.anchorRef.current) || tooltipNode === popover.anchorRef.current)) {
if (
isOpen &&
popover &&
popover.anchorRef &&
popover.anchorRef.current &&
tooltipNode &&
(tooltipNode.contains(popover.anchorRef.current) || tooltipNode === popover.anchorRef.current)
) {
return true;
}

Expand Down

0 comments on commit 6316669

Please sign in to comment.