fix(dashboard-v2): fix CopyButton's timeout
This commit is contained in:
parent
2e871f4712
commit
539fc32fb9
|
@ -22,7 +22,7 @@ const TooltipContent = styled.div.attrs({
|
||||||
className: "bg-primary-light/10 text-palette-600 py-2 px-4 ",
|
className: "bg-primary-light/10 text-palette-600 py-2 px-4 ",
|
||||||
})``;
|
})``;
|
||||||
|
|
||||||
export const CopyButton = ({ value }) => {
|
export const CopyButton = ({ value, className }) => {
|
||||||
const containerRef = useRef();
|
const containerRef = useRef();
|
||||||
const [copied, setCopied] = useState(false);
|
const [copied, setCopied] = useState(false);
|
||||||
const [timer, setTimer] = useState(null);
|
const [timer, setTimer] = useState(null);
|
||||||
|
@ -32,13 +32,13 @@ export const CopyButton = ({ value }) => {
|
||||||
copy(value);
|
copy(value);
|
||||||
setCopied(true);
|
setCopied(true);
|
||||||
|
|
||||||
setTimer(setTimeout(() => setCopied(false), 150000));
|
setTimer(setTimeout(() => setCopied(false), 1500));
|
||||||
}, [value, timer]);
|
}, [value, timer]);
|
||||||
|
|
||||||
useClickAway(containerRef, () => setCopied(false));
|
useClickAway(containerRef, () => setCopied(false));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div ref={containerRef} className="inline-flex relative overflow-visible pr-2">
|
<div ref={containerRef} className={`inline-flex relative overflow-visible pr-2 ${className ?? ""}`}>
|
||||||
<Button onClick={handleCopy} className={copied ? "text-primary" : ""}>
|
<Button onClick={handleCopy} className={copied ? "text-primary" : ""}>
|
||||||
<CopyIcon size={16} />
|
<CopyIcon size={16} />
|
||||||
</Button>
|
</Button>
|
||||||
|
|
Reference in New Issue