From 6b363e1eb2525c0f560838e600eed765e7c2eff2 Mon Sep 17 00:00:00 2001 From: Razvan Stoenescu Date: Wed, 11 Jan 2023 11:24:19 +0200 Subject: [PATCH] fix(ui): copyToClipboard fallback mechanism in dialog #15076 --- ui/src/utils/copy-to-clipboard.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ui/src/utils/copy-to-clipboard.js b/ui/src/utils/copy-to-clipboard.js index c951828413b..dc08959b429 100644 --- a/ui/src/utils/copy-to-clipboard.js +++ b/ui/src/utils/copy-to-clipboard.js @@ -1,9 +1,15 @@ + +import { addFocusout, removeFocusout } from './private/focusout.js' + function fallback (text) { const area = document.createElement('textarea') area.value = text area.contentEditable = 'true' area.style.position = 'fixed' // avoid scrolling to bottom + const fn = () => {} + addFocusout(fn) + document.body.appendChild(area) area.focus() area.select() @@ -11,6 +17,8 @@ function fallback (text) { const res = document.execCommand('copy') area.remove() + removeFocusout(fn) + return res }