Bug 38703

Summary: user-select none should not clear selection
Product: WebKit Reporter: Erik Arvidsson <arv>
Component: HTML EditingAssignee: Nobody <webkit-unassigned>
Status: NEW    
Severity: Normal CC: ap, arv, caleb, enrica, gmak, megan_gardner, neil.ashford, rniwa, wenson_hsieh
Priority: P2 Keywords: HasReduction
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Bug Depends on:    
Bug Blocks: 208677    
Attachments:
Description Flags
Test
none
An extra HTML file with a similar (possibly the same) issue none

Erik Arvidsson
Reported 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
Attachments
Test (174 bytes, text/html)
2010-05-06 16:04 PDT, Erik Arvidsson
no flags
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
gmak
Comment 1 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.
Neil Ashford
Comment 2 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.
Caleb Hearon
Comment 3 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.
Note You need to log in before you can comment on or make changes to this bug.