Commit a53eae04 authored by Igor Stuev's avatar Igor Stuev Committed by GitHub

Merge pull request #704 from blockscout/copy-tooltip-fix

copy to clipboard tooltip fix
parents 9dfd4a93 419edea8
...@@ -35,8 +35,8 @@ const Deposits = () => { ...@@ -35,8 +35,8 @@ const Deposits = () => {
<Skeleton <Skeleton
w={{ base: '100%', lg: '320px' }} w={{ base: '100%', lg: '320px' }}
h="24px" h="24px"
mb={{ base: 6, lg: isPaginationVisible ? 0 : 7 }} mb={{ base: 7, lg: isPaginationVisible ? 0 : 7 }}
mt={{ base: 0, lg: isPaginationVisible ? 0 : 7 }} mt={{ base: 1, lg: isPaginationVisible ? 0 : 7 }}
/> />
); );
} }
...@@ -46,7 +46,7 @@ const Deposits = () => { ...@@ -46,7 +46,7 @@ const Deposits = () => {
} }
return ( return (
<Text mb={{ base: 6, lg: isPaginationVisible ? 0 : 6 }} lineHeight="32px"> <Text mb={{ base: 6, lg: isPaginationVisible ? 0 : 6 }} lineHeight={{ base: '24px', lg: '32px' }}>
A total of { countersQuery.data.toLocaleString('en') } deposits found A total of { countersQuery.data.toLocaleString('en') } deposits found
</Text> </Text>
); );
......
...@@ -46,7 +46,7 @@ const Withdrawals = () => { ...@@ -46,7 +46,7 @@ const Withdrawals = () => {
} }
return ( return (
<Text mb={{ base: 6, lg: isPaginationVisible ? 0 : 6 }} lineHeight="32px"> <Text mb={{ base: 6, lg: isPaginationVisible ? 0 : 6 }} lineHeight={{ base: '24px', lg: '32px' }}>
A total of { countersQuery.data.toLocaleString('en') } withdrawals found A total of { countersQuery.data.toLocaleString('en') } withdrawals found
</Text> </Text>
); );
......
...@@ -4,10 +4,10 @@ import React, { useEffect, useState } from 'react'; ...@@ -4,10 +4,10 @@ import React, { useEffect, useState } from 'react';
import CopyIcon from 'icons/copy.svg'; import CopyIcon from 'icons/copy.svg';
const CopyToClipboard = ({ text, className }: {text: string; className?: string}) => { const CopyToClipboard = ({ text, className }: {text: string; className?: string}) => {
const { hasCopied, onCopy } = useClipboard(text, 3000); const { hasCopied, onCopy } = useClipboard(text, 1000);
const [ copied, setCopied ] = useState(false); const [ copied, setCopied ] = useState(false);
// have to implement controlled tooltip because of the issue - https://github.com/chakra-ui/chakra-ui/issues/7107 // have to implement controlled tooltip because of the issue - https://github.com/chakra-ui/chakra-ui/issues/7107
const { isOpen, onOpen, onToggle, onClose } = useDisclosure(); const { isOpen, onOpen, onClose } = useDisclosure();
useEffect(() => { useEffect(() => {
if (hasCopied) { if (hasCopied) {
...@@ -17,13 +17,8 @@ const CopyToClipboard = ({ text, className }: {text: string; className?: string} ...@@ -17,13 +17,8 @@ const CopyToClipboard = ({ text, className }: {text: string; className?: string}
} }
}, [ hasCopied ]); }, [ hasCopied ]);
const handleClick = React.useCallback(() => {
onToggle();
onCopy();
}, [ onCopy, onToggle ]);
return ( return (
<Tooltip label={ copied ? 'Copied' : 'Copy to clipboard' } isOpen={ isOpen }> <Tooltip label={ copied ? 'Copied' : 'Copy to clipboard' } isOpen={ isOpen || copied }>
<IconButton <IconButton
aria-label="copy" aria-label="copy"
icon={ <CopyIcon/> } icon={ <CopyIcon/> }
...@@ -32,7 +27,7 @@ const CopyToClipboard = ({ text, className }: {text: string; className?: string} ...@@ -32,7 +27,7 @@ const CopyToClipboard = ({ text, className }: {text: string; className?: string}
variant="simple" variant="simple"
display="inline-block" display="inline-block"
flexShrink={ 0 } flexShrink={ 0 }
onClick={ handleClick } onClick={ onCopy }
className={ className } className={ className }
onMouseEnter={ onOpen } onMouseEnter={ onOpen }
onMouseLeave={ onClose } onMouseLeave={ onClose }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment