From 4de6b494e81afb2c14dbb6774cda28871661d119 Mon Sep 17 00:00:00 2001 From: Michael Yankelev Date: Thu, 18 Nov 2021 12:44:07 +0200 Subject: [PATCH] Revert "copy working" This reverts commit 424f4278a558c64d6d9317693aa40a4ee477dd03. --- .../FileBrowsers/LinkSharing/SharingLink.tsx | 49 +++++++++---------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/packages/files-ui/src/Components/Modules/FileBrowsers/LinkSharing/SharingLink.tsx b/packages/files-ui/src/Components/Modules/FileBrowsers/LinkSharing/SharingLink.tsx index 347dcb5414..adc8cca9f3 100644 --- a/packages/files-ui/src/Components/Modules/FileBrowsers/LinkSharing/SharingLink.tsx +++ b/packages/files-ui/src/Components/Modules/FileBrowsers/LinkSharing/SharingLink.tsx @@ -158,43 +158,40 @@ const SharingLink = ({ nonce, bucketEncryptionKey, refreshNonces }: Props) => { const debouncedSwitchCopied = debounce(() => setCopied(false), 3000) - const onCopyInfo = useCallback(() => { - // this doesn't work on Mobile - // navigator.clipboard.writeText(link) - // .then(() => { - // setCopied(true) - // debouncedSwitchCopied() - // }) - // .catch(console.error) + navigator.clipboard.writeText(link) + .then(() => { + setCopied(true) + debouncedSwitchCopied() + }) + .catch(console.error) - //Create a textbox field where we can insert text to. - const copyFrom = document.createElement("textarea") + // //Create a textbox field where we can insert text to. + // const copyFrom = document.createElement("textarea") - //Set the text content to be the text you wished to copy. - copyFrom.textContent = link + // //Set the text content to be the text you wished to copy. + // copyFrom.textContent = link - //Append the textbox field into the body as a child. - //"execCommand()" only works when there exists selected text, and the text is inside - //document.body (meaning the text is part of a valid rendered HTML element). - document.body.appendChild(copyFrom) + // //Append the textbox field into the body as a child. + // //"execCommand()" only works when there exists selected text, and the text is inside + // //document.body (meaning the text is part of a valid rendered HTML element). + // document.body.appendChild(copyFrom) - //Select all the text! - copyFrom.select() + // //Select all the text! + // copyFrom.select() - //Execute command - document.execCommand("copy") + // //Execute command + // document.execCommand("copy") - //(Optional) De-select the text using blur(). - copyFrom.blur() + // //(Optional) De-select the text using blur(). + // copyFrom.blur() - //Remove the textbox field from the document.body, so no other JavaScript nor - //other elements can get access to this. - document.body.removeChild(copyFrom) + // //Remove the textbox field from the document.body, so no other JavaScript nor + // //other elements can get access to this. + // document.body.removeChild(copyFrom) setCopied(true) debouncedSwitchCopied() - }, [debouncedSwitchCopied, link]) const onDeleteNonce = useCallback(() => {