Open Bug 2000366 Opened 1 year ago Updated 2 days ago

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)

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)

Attached image GmailSent.png —

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).

Attached image TwitterCopyLink.png —

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.

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.

Component: General → DOM: Copy & Paste and Drag & Drop
Product: Firefox → Core

Or X is doing something wrong.

Component: DOM: Copy & Paste and Drag & Drop → Site Reports
Product: Core → Web Compatibility
Severity: -- → S3
User Story: (updated)
Webcompat Priority: --- → P2
Webcompat Score: --- → 6
Priority: -- → P2
Whiteboard: [webcompat:sightline][webcompat:japan]

Edgar, can you take a look?

Flags: needinfo?(echen)
User Story: (updated)

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
          }
User Story: (updated)
Attached file test.html —

This is reduced test case to reproduce the behavior.

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.

Flags: needinfo?(echen)

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.

I filed bug 2002879.

Depends on: 2002879
Whiteboard: [webcompat:sightline][webcompat:japan] → [webcompat:sightline][webcompat:japan][webcompat:core]

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?

Flags: needinfo?(billdillensrevenge)

I can still see the option to copy the link when I click the Share button on a post.

I can no longer repro

Flags: needinfo?(billdillensrevenge)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: