From b2d9814a918cde8e2bae6bb32349008638fd0ad9 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Mon, 18 Dec 2023 18:09:27 +0100 Subject: [PATCH] fix wallet button tooltip --- ui/snippets/walletMenu/WalletTooltip.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ui/snippets/walletMenu/WalletTooltip.tsx b/ui/snippets/walletMenu/WalletTooltip.tsx index 7a769fe374..60e7bb1929 100644 --- a/ui/snippets/walletMenu/WalletTooltip.tsx +++ b/ui/snippets/walletMenu/WalletTooltip.tsx @@ -1,4 +1,4 @@ -import { Tooltip, useBoolean } from '@chakra-ui/react'; +import { Tooltip, useBoolean, useOutsideClick } from '@chakra-ui/react'; import React from 'react'; type Props = { @@ -9,6 +9,8 @@ type Props = { const WalletTooltip = ({ children, isDisabled, isMobile }: Props) => { const [ isTooltipShown, setIsTooltipShown ] = useBoolean(false); + const ref = React.useRef(null); + useOutsideClick({ ref, handler: setIsTooltipShown.off }); React.useEffect(() => { const key = `wallet-connect-tooltip-shown-${ isMobile ? 'mobile' : 'desktop' }`; @@ -29,6 +31,7 @@ const WalletTooltip = ({ children, isDisabled, isMobile }: Props) => { isOpen={ isTooltipShown || (isMobile ? false : undefined) } onClose={ setIsTooltipShown.off } display={ isMobile ? { base: 'flex', lg: 'none' } : { base: 'none', lg: 'flex' } } + ref={ ref } > { children }