|
@@ -13,9 +13,9 @@ const CopyButton: FC<CopyButtonProps> = props => {
|
|
|
const { t: commonTrans } = useTranslation();
|
|
|
const copyTrans = commonTrans('copy');
|
|
|
const [tooltipTitle, setTooltipTitle] = useState('Copy');
|
|
|
-
|
|
|
+
|
|
|
const unsecuredCopyToClipboard = (v: string) => {
|
|
|
- const textArea = document.createElement("textarea");
|
|
|
+ const textArea = document.createElement('textarea');
|
|
|
textArea.style.position = 'fixed';
|
|
|
textArea.style.opacity = '0';
|
|
|
textArea.style.zIndex = '-1000';
|
|
@@ -29,13 +29,13 @@ const CopyButton: FC<CopyButtonProps> = props => {
|
|
|
console.error('Unable to copy to clipboard', err);
|
|
|
}
|
|
|
document.body.removeChild(textArea);
|
|
|
- }
|
|
|
-
|
|
|
+ };
|
|
|
+
|
|
|
const handleClick = (event: React.MouseEvent<HTMLElement>, v: string) => {
|
|
|
event.stopPropagation();
|
|
|
|
|
|
setTooltipTitle(copyTrans.copied);
|
|
|
- (navigator.clipboard?.writeText ?? unsecuredCopyToClipboard)?.(v);
|
|
|
+ navigator.clipboard?.writeText(v) ?? unsecuredCopyToClipboard(v);
|
|
|
setTimeout(() => {
|
|
|
setTooltipTitle(copyTrans.copy);
|
|
|
}, 1000);
|