Open Bug 1678667 Opened 4 years ago Updated 3 years ago

`user-select: none` element in contenteditable is excluded from copy-to-clipboard

Categories

(Core :: DOM: Copy & Paste and Drag & Drop, defect, P3)

defect

Tracking

()

People

(Reporter: saschanaz, Unassigned)

References

Details

Attachments

(1 file)

Attached file user-select-none-contenteditable.html (deleted) —
  1. Try selecting the whole line.
  2. Copy-paste to somewhere else.

Expected: No selection for "noselect" span element
Actual: It's selected but omitted in clipboard, causing confusion

This also causes a web-visible behavior difference: getSelection().rangeCount becomes 2 without contenteditable but 1 with contenteditable.

I seem to recall it's intentional that user-select: none is ignored inside a contenteditable node - otherwise you wouldn't be able to edit it. Omitting it when it's copied to the clipboard seems like a bug though. I think the serialization/clipboard code has its own handling of user-select: none which we should probably nuke and just use the Ranges instead. (It was a long time ago that I hacked on Selection though, so I could be wrong.)

Component: Layout → DOM: Selection

(In reply to Mats Palmgren (:mats) from comment #1)

I seem to recall it's intentional that user-select: none is ignored inside a contenteditable node - otherwise you wouldn't be able to edit it. Omitting it when it's copied to the clipboard seems like a bug though. I think the serialization/clipboard code has its own handling of user-select: none which we should probably nuke and just use the Ranges instead. (It was a long time ago that I hacked on Selection though, so I could be wrong.)

Yes, the serialization-code skips content with unselectable frames.

Given what Mats wrote above, it seems nsIFrame::IsSelectable should return true when the frame corresponds to a node which is contenteditable.

Severity: -- → S3
Priority: -- → P3
Summary: `user-select: none` element in contenteditable can unexpectedly be selected → `user-select: none` element in contenteditable is excluded from copy-to-clipboard
Component: DOM: Selection → DOM: Copy & Paste and Drag & Drop
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: