diff --git a/react/features/base/buttons/CopyButton.js b/react/features/base/buttons/CopyButton.js index a99ba7cc5..c8a6256dd 100644 --- a/react/features/base/buttons/CopyButton.js +++ b/react/features/base/buttons/CopyButton.js @@ -2,9 +2,9 @@ import React, { useState } from 'react'; -import { translate } from '../../base/i18n'; import { Icon, IconCheck, IconCopy } from '../../base/icons'; -import { copyText } from '../../base/util'; +import { translate } from '../i18n'; +import { copyText } from '../util'; type Props = { diff --git a/react/features/base/util/helpers.js b/react/features/base/util/helpers.js index 53c41780c..0408c6409 100644 --- a/react/features/base/util/helpers.js +++ b/react/features/base/util/helpers.js @@ -31,24 +31,15 @@ export function assignIfDefined(target: Object, source: Object) { * @param {string} textToCopy - Text to be copied. * @returns {boolean} */ -export function copyText(textToCopy: string) { - const fakeTextArea = document.createElement('textarea'); +export async function copyText(textToCopy: string) { let result; - // $FlowFixMe - document.body.appendChild(fakeTextArea); - fakeTextArea.value = textToCopy; - fakeTextArea.select(); - try { - result = document.execCommand('copy'); + result = await navigator.clipboard.writeText(textToCopy); } catch (err) { result = false; } - // $FlowFixMe - document.body.removeChild(fakeTextArea); - return result; }