Bug 38703 - user-select none should not clear selection
Summary: user-select none should not clear selection
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: HTML Editing (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords: HasReduction
Depends on:
Blocks:
 
Reported: 2010-05-06 16:04 PDT by Erik Arvidsson
Modified: 2021-04-20 09:17 PDT (History)
9 users (show)

See Also:


Attachments
Test (174 bytes, text/html)
2010-05-06 16:04 PDT, Erik Arvidsson
no flags Details
An extra HTML file with a similar (possibly the same) issue (454 bytes, text/html)
2021-02-08 23:41 PST, Neil Ashford
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Erik Arvidsson 2010-05-06 16:04:18 PDT
Created attachment 55315 [details]
Test 

If I have some selected text and then do a mousedown on an element that has user-select none the current selection should not be cleared.

The code to fix this is in Node::canStartSelection.

if (style->userDrag() == DRAG_ELEMENT && style->userSelect() == SELECT_NONE)

should be changed to

if (style->userDrag() == DRAG_ELEMENT || style->userSelect() == SELECT_NONE)

The following two LayoutTests needs to be updated as well:

editing/selection/5333725.html
editing/selection/user-drag-element-and-user-select-none.html
Comment 1 gmak 2010-08-25 10:48:18 PDT
Does this need #if ENABLE(DRAG_SUPPORT) flags as well? It will probably work fine without with the proposed change but all other uses of userDrag() have the define wrapped around it somewhere.
Comment 2 Neil Ashford 2021-02-08 23:41:15 PST
Created attachment 419682 [details]
An extra HTML file with a similar (possibly the same) issue

The same issue, but specifically where the first selection is in a content editable element, is affecting my product. I'm using Safari 14.0.2 on MacOS 11.1, so it looks like this bug (or some variant of it) is still happening.
Comment 3 Caleb Hearon 2021-04-20 08:46:10 PDT
Based on the "Test" attachment, the original bug looks fixed: clicking on `-webkit-user-select: none` doesn't destroy text selection. But like Neil said, it _does_ destroy selection if the selection is in [contentEditable].

This makes it really difficult to support Safari if you have a WYSIWYG editor and have div-based controls that operate on the selection. You want the selection to stay the same while the user formats it.

Oddly the native <button> passes the test cases in both attachments.