From 6155645a4549c1e85680dcf77eea549dcd9412d8 Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Tue, 5 Oct 2021 15:32:23 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fixed=20copy-to-clipboard=20butt?= =?UTF-8?q?ons=20in=20Chrome=20+=20Firefox?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit no issue - the method we used for copying text to the clipboard for older browsers has broken on some newer browsers - the more modern `navigator.clipboard.writeText` API is now universally supported by our target browsers so we're able to switch to that instead which is working across the board --- ghost/admin/app/utils/copy-text-to-clipboard.js | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/ghost/admin/app/utils/copy-text-to-clipboard.js b/ghost/admin/app/utils/copy-text-to-clipboard.js index 386ab42d3c..2a668f373c 100644 --- a/ghost/admin/app/utils/copy-text-to-clipboard.js +++ b/ghost/admin/app/utils/copy-text-to-clipboard.js @@ -1,11 +1,3 @@ export default function copyTextToClipboard(text) { - let textarea = document.createElement('textarea'); - textarea.value = text; - textarea.setAttribute('readonly', ''); - textarea.style.position = 'absolute'; - textarea.style.left = '-9999px'; - document.body.appendChild(textarea); - textarea.select(); - document.execCommand('copy'); - document.body.removeChild(textarea); + navigator.clipboard.writeText(text); }