mistercrunch closed pull request #3923: [Bugfix] Copy to clipboard adds newline
URL: https://github.com/apache/incubator-superset/pull/3923
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/superset/assets/javascripts/components/CopyToClipboard.jsx
b/superset/assets/javascripts/components/CopyToClipboard.jsx
index 7288b0d556..593e0b0575 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 {
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services