This is an automated email from the ASF dual-hosted git repository.

songjian pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git


The following commit(s) were added to refs/heads/dev by this push:
     new 99678c097c [Fix][UI Next][V1.0.0-Beta] Fix bug where name copy is 
invalid (#9684)
99678c097c is described below

commit 99678c097c3a80757172aca038c4df15117effc4
Author: Devosend <[email protected]>
AuthorDate: Sun Apr 24 11:56:58 2022 +0800

    [Fix][UI Next][V1.0.0-Beta] Fix bug where name copy is invalid (#9684)
---
 dolphinscheduler-ui-next/src/utils/clipboard.ts | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/dolphinscheduler-ui-next/src/utils/clipboard.ts 
b/dolphinscheduler-ui-next/src/utils/clipboard.ts
index e4f5e7f420..714ea52663 100644
--- a/dolphinscheduler-ui-next/src/utils/clipboard.ts
+++ b/dolphinscheduler-ui-next/src/utils/clipboard.ts
@@ -16,16 +16,14 @@
  */
 
 export const copy = (text: string): boolean => {
-  const range = document.createRange()
-  const node = document.createTextNode(text)
-  document.body.append(node)
-  range.selectNode(node)
-  window.getSelection()?.addRange(range)
+  const inp = document.createElement('input')
+  document.body.appendChild(inp)
+  inp.value = text
+  inp.select()
   let result = false
   try {
     result = document.execCommand('copy')
   } catch (err) {}
-  window.getSelection()?.removeAllRanges()
-  document.body.removeChild(node)
+  inp.remove()
   return result
 }

Reply via email to