Closed Bug 1680893 Opened 4 years ago Closed 4 years ago

Css values are not copied to clipboard if checkbox to enable / disable them is selected as well

Categories

(DevTools :: Inspector: Rules, defect, P2)

Firefox 85
Unspecified
Windows
defect

Tracking

(firefox86 fixed)

RESOLVED FIXED
86 Branch
Tracking Status
firefox86 --- fixed

People

(Reporter: christoph.mosimann, Assigned: nchevobbe)

References

Details

Attachments

(2 files)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:83.0) Gecko/20100101 Firefox/83.0

Steps to reproduce:

  1. Open the inspector, inspect an element
  2. Click to the right side of the element, click and hold the left mouse button down and drag the cursor to the left until full element is selected (name+value+checkbox). Make sure to drag the cursor to the left fully to the left side of the activation checkbox)
  3. Hit ctrl + c
  4. Example:
    [x] color: black; <- Click here and drag cursor to the left to select the line.
    4.1 If cursor is dragged over the checkbox [x], line can't be copied using ctrl+c
    That's just annoying.

Actual results:

The element (setting and value) is not copied to clipboard. Only way to copy is to precisely not select the checkbox to enable / disable the target css element.

Expected results:

It should be copied to the clipboard in any case.

Component: Untriaged → Inspector: Rules
Product: Firefox → DevTools
Severity: -- → S3
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Unspecified → Windows
Priority: -- → P2

Likely a duplicate of Bug 1650125 (Windows) and Bug 1635618 (Ubuntu). Couldn't reproduce either on macOS.
I suggest keeping this instead because it has clearer steps to reproduce.

Possible root causes:

This is the faulty code: https://searchfox.org/mozilla-central/rev/4415bec7a49c50a338167d9c8934527b9cae59d0/devtools/client/inspector/rules/rules.js#556-568

Here, with Comment 0 STR, the target is the checkbox, which is an input, so it goes into the first if block where retrieve the selectionStart/End from said target. Here with the checkbox, it will be null, and in the end this will produce an empty string.

I'm going to take this

Assignee: nobody → nchevobbe
Status: NEW → ASSIGNED

When selecting something in the rule view, if the user
moused up right onto the enable/disable rule checkbox,
and then tried to copy the selection, the clipboard was empty.
This is due to copySelection checking the target of the copy
event and doing something special if it is an input or a textarea.

To fix this, we add an extra check to test if the input isn't
a checkbox.

A test case, failing without the fix, is added to ensure we don't
regress this.

I can confirm that the bug also happens on Ubuntu, and that my patch fixes the issue there as well :)

Thank you for the investigation and for fixing this, Nicolas! I marked the other bugs as duplicates of this one.

Pushed by nchevobbe@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/ab3fc36c2fd7 [devtools] Fix copy rule when the user ended the selection over the rule checkbox. r=rcaliman.
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 86 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: