Text and/or links from Twitter's built in "Copy link" button are invisible when pasted in Gmail
Categories
(Web Compatibility :: Site Reports, defect, P2)
Tracking
(Webcompat Priority:P2, Webcompat Score:6)
People
(Reporter: billdillensrevenge, Unassigned)
References
()
Details
(Keywords: webcompat:needs-contact, webcompat:platform-bug, webcompat:site-report, Whiteboard: [webcompat:sightline][webcompat:japan][webcompat:core])
User Story
platform:windows,mac,linux impact:feature-broken configuration:general affects:all branch:release diagnosis-team:dom user-impact-score:450
Attachments
(3 files)
Text and/or links from Twitter's built in "Copy link" button are invisible when pasted into Gmail compose email. I cannot repro in Chrome.
Repro steps: go to a tweet, click the tweets "Share" button and then click "Copy link", now go to the Gmail website, click the "Compose" new email button and paste, observe that the link/text is invisible. It's there but invisible. When you send the email, the text is visible in the in the email list but when you click on the email, it's not visible in the body. I attached a screenshot of this (rectangle is around where the invisible link is).
Just to be clear, this is the button you have to click. If you copy/cut the link from Firefox's URL bar, there is no issue.
The reason I filed this bug is because I'm confident it is not specific to twitter and Gmail, I'm pretty sure I've experienced it elsewhere but I can't remember where.
Comment 2•1 year ago
•
|
||
I can reproduce the issue.
Copy Link of X on Firefox. then Paste to Gmail on Firefox → Invisible text as a result
Copy Link of X on Firefox. then Paste to Gmail on Chrome → ditto
Copy Link of X on Chrome. then Paste to Gmail on Firefox → visible text (white text/black background) as a result
Copy Link of X on Chrome. then Paste to Gmail on Chome → ditto
So, the Copy link feature on X pages in Firefox seems to be going wrong.
Updated•1 year ago
|
Comment 3•1 year ago
|
||
Or X is doing something wrong.
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Comment 5•1 year ago
•
|
||
X create a temporary <span> element with opacity CSS property set to 0 and select it, then trigger copy action via execCommand("copy").
We serialize all CSS property for text/html format while copying, whereas other browser drop the opacity property ....
And gmail uses the text/html data if any while pasting, that is why the paste content is invisible there.
The relevant code is in https://abs.twimg.com/responsive-web/client-web/vendor.7bf0e88a.js
static setString(e) {
var t = !1,
r = document.body;
if (r) {
var n = document.createElement('span');
n.textContent = e,
n.style.opacity = '0',
n.style.position = 'absolute',
n.style.whiteSpace = 'pre-wrap',
n.style.userSelect = 'auto',
r.appendChild(n);
var i = window.getSelection();
i.removeAllRanges();
var o = document.createRange();
o.selectNodeContents(n),
i.addRange(o);
try {
document.execCommand('copy'),
t = !0
} catch (e) {
}
i.removeAllRanges(),
r.removeChild(n)
}
return t
}
Comment 6•1 year ago
|
||
This is reduced test case to reproduce the behavior.
Comment 7•1 year ago
|
||
The temporary <span> element is appended to <body>, I think X set it to opacity = '0' in order to make it invisible to the user.
The serialization behavior for copying isn't defined in the spec. So I consider this is a bug in X.
Instead of selecting a invisible for copying, they can also handle the "copy" event and update the clipboard content via ClipboardEvent.clipboardData, or use async clipboard API. This way, they don’t need to append an invisible element.
Comment 8•1 year ago
|
||
Is there a practical reason not to align with other browsers here? It doesn't feel very theoretically pure to treat opacity specially, but from a user / developer point of view I'm struggling to think of a use case for pasting text with zero opacity, and aligning with other browsers means we won't see similar site bugs in the future unless other browser change their behaviour.
Updated•8 months ago
|
Comment 10•6 days ago
|
||
The page has received an UI update. I can't see the option to copy link from a post. Will, maybe I am missing something?
Comment 11•5 days ago
|
||
I can still see the option to copy the link when I click the Share button on a post.
Description
•