Open Bug 1751757 Opened 4 years ago Updated 6 days ago

triple click selection primary clipboard broken inside slack.com's code blocks

Categories

(Core :: DOM: Selection, defect, P3)

Firefox 96
Unspecified
Linux
defect

Tracking

()

Tracking Status
firefox99 --- affected

People

(Reporter: mbagnara, Unassigned)

Details

(Keywords: parity-chrome)

Steps to reproduce:

On websites such as app.slack.com that rely on <code> blocks to generate code snippets, I usually triple-click the contents of the code blocks to copy the text to my primary selection clipboard.

This behaviour acts normal with regular paragraph text..

Actual results:

<code>this is a test</code>

If I triple click any of the words in the content, it highlights the entire string, but when I go to paste from primary clipboard, it only contains the single word I clicked on.

Expected results:

Entire selection should be copied to the prymary primary

The Bugbug bot thinks this bug should belong to the 'Core::DOM: Selection' component, and is moving the bug to that component. Please revert this change in case you think the bot is wrong.

Component: Untriaged → DOM: Selection
Product: Firefox → Core

The severity field is not set for this bug.
:peterv, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(peterv)

I couldn't reproduce this. I was using Win11.
When I triple-clicked a certain word, the whole string was highlighted. Then when I copied and pasted over, I got the whole string as expected.

Let's have one more engineer to verify the behavior.

Flags: needinfo?(peterv) → needinfo?(mbrodesser)

Reproducible on Ubuntu 20.04.

Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: needinfo?(mbrodesser)

This doesn't affect <code> elements in general, e.g. triple-clicking in

data:text/html,<code>abc def</code>

works.

Likely, this is a bug on slack.com.

Dennis: can you please take a look and potentially forward to a Slack engineer?

Flags: needinfo?(dschubert)
Summary: triple click selection primary clipboard broken inside <code> blocks → triple click selection primary clipboard broken inside slack.com's code blocks

Btw, code snippets on slack.com are <pre>s.

I should have clarified if my user-agent is not attached to the BZ, I am running Linux 5.16.10-arch1-1 x86_64 GNU/Linux on Wayland. I am using the primary selection clipboard so this confirms reproducibility in Ubuntu.

(In reply to Mirko Brodesser (:mbrodesser) from comment #6)

Btw, code snippets on slack.com are <pre>s.

I see there are two modes on slack.com - <pre> is for "code block" and <code> is for "code"

(In reply to Hsin-Yi Tsai [:hsinyi] from comment #8)

(In reply to Mirko Brodesser (:mbrodesser) from comment #6)

Btw, code snippets on slack.com are <pre>s.

I see there are two modes on slack.com - <pre> is for "code block" and <code> is for "code"

Right. Thanks for mentioning that. Both are broken.

To be explicit, copy-pasting via Ctrl+c and Ctrl+v works. Copying via the click and pasting via clicking the middle mouse button is broken.

Works with Chrome.
With Chrome there's no onMouseDown event listener for the <pre> element, so it still looks like a Firefox-specific bug of <slack.com>.

Smaller example to reproduce the issue: https://jsfiddle.net/6oxb7avs/

Calling range.selectNodeContents() and selection.addRange() doesn't update the clipboard. With Chrome, it does.

The spec for selection.addRange doesn't specify whether the clipboard should be updated.

Interesting, Chrome doesn't always update the Selection. For instance, when Selection.addRange() is called when JS is loaded, the clipboard is not updated. In a click event handler, it is. https://jsfiddle.net/cuwr3bt6/1/ illustrates the latter.
So this might depend on user-activation.

@dschubert: we should first clarify the desired behavior, before that it might not make sense to contact slack.com-developers. Although I wonder why <slack.com> has the Firefox-specific code.

Flags: needinfo?(dschubert)

Prioritizing as P3, since only Linux supports a separate clipboard which copies when changing the selection.

The right way forward here is to specify what's actually desired.

Severity: -- → S3
OS: Unspecified → Linux
Priority: -- → P3

With Firefox 150.0.1, I have the same issue with the GLPI ticket system, but there are no <code> blocks:

  1. A triple-click on a word selects the whole line.
  2. Pasting the PRIMARY selection pastes this word only (instead of the whole line).
  3. Copying the selection to the clipboard puts the whole selection to the clipboard, though.
You need to log in before you can comment on or make changes to this bug.