This is an automated email from the ASF dual-hosted git repository.
maximebeauchemin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
The following commit(s) were added to refs/heads/master by this push:
new 5466fab Switched to span instead of textarea for copytoclipboard
(#3923)
5466fab is described below
commit 5466fab2a01cdddb21cba8e9e87f1475c18b9140
Author: Jeff Niu <[email protected]>
AuthorDate: Tue Nov 21 22:09:41 2017 -0800
Switched to span instead of textarea for copytoclipboard (#3923)
---
.../javascripts/components/CopyToClipboard.jsx | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/superset/assets/javascripts/components/CopyToClipboard.jsx
b/superset/assets/javascripts/components/CopyToClipboard.jsx
index 7288b0d..593e0b0 100644
--- a/superset/assets/javascripts/components/CopyToClipboard.jsx
+++ b/superset/assets/javascripts/components/CopyToClipboard.jsx
@@ -56,14 +56,16 @@ export default class CopyToClipboard extends
React.Component {
selection.removeAllRanges();
document.activeElement.blur();
const range = document.createRange();
- const textArea = document.createElement('textarea');
-
- textArea.style.position = 'fixed';
- textArea.style.left = '-1000px';
- textArea.value = textToCopy;
-
- document.body.appendChild(textArea);
- range.selectNode(textArea);
+ const span = document.createElement('span');
+ span.textContent = textToCopy;
+ span.style.all = 'unset';
+ span.style.position = 'fixed';
+ span.style.top = 0;
+ span.style.clip = 'rect(0, 0, 0, 0)';
+ span.style.whiteSpace = 'pre';
+
+ document.body.appendChild(span);
+ range.selectNode(span);
selection.addRange(range);
try {
if (!document.execCommand('copy')) {
@@ -73,7 +75,7 @@ export default class CopyToClipboard extends React.Component {
window.alert(t('Sorry, your browser does not support copying. Use Ctrl /
Cmd + C!')); // eslint-disable-line
}
- document.body.removeChild(textArea);
+ document.body.removeChild(span);
if (selection.removeRange) {
selection.removeRange(range);
} else {
--
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].