New issue
Advanced search Search tips

Issue 861673 link

Starred by 3 users

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows , Mac
Pri: 3
Type: Bug



Sign in to add a comment

Clicking outside BODY element should make selection empty

Reported by k.litwin...@cksource.com, Jul 9

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36

Steps to reproduce the problem:
1. Create and open simple html file like following:

`<html><body contenteditable='true'>Text</body></html>`

2. Open console, and select text.

3. Click once below text.

4. Type in console:
`document.activeElement` // Logs body as active element
`document.getSelection()` // Chrome and Opera logs selection with 0 ranges
But Firefox and Safari logs selection at the end of editable textnode. And this is what I would expect from browser in such case. 

5. Place collapsed selection at the end of word 'Text'.

6. Click below text.

7. Type in console:
`document.getSelection()` // Here Chrome logs collapsed selection which represents last caret position. Which actually makes sense, but this is inconsistent behaviour comparing to step 4.

What is the expected behavior?
In step 4 Chrome should behave in same way as in step 7.

What went wrong?
In step 4 selection has no ranges.

Did this work before? N/A 

Does this work in other browsers? N/A

Chrome version: 67.0.3396.99  Channel: stable
OS Version: OS X 10.13.5
Flash Version:
 
testfile.html
69 bytes View Download
Components: Blink>Editing
Labels: Needs-Triage-M67
Components: -Blink>Editing Blink>Editing>Selection
Status: WontFix (was: Unconfirmed)
Mark WontFix since
- I could not reproduce. When I click below "Text" after make selection range and place collapsed selection at end of "Text".
- Hit testing returns null position for outside of viewport

On Edge and Firefox, dragging mouse below "Text" makes range selection but Chrome
doesn't.


Comment 4 Deleted

yosin@chromium.org in order to reproduce this problem you need to select text and then click on any `body` element `margin` (top, bottom, right or left). I have modified a testfile.html by adding bigger margins so that it is easier to reproduce. 
In Chrome, clicking on a `margin` and then executing `document.getSelection()` returns `rangeCount` 0 while in browsers like Firefox the reangeCount is 1. Executing `document.activeElement` returns `body` element for both browsers. Taking that into account, I don't this Chrome behavior is correct. 

NOTE: You can check where the `body` margins are by selecting the `body` element with Element Selector in Chrome dev-tools. Margins will be salmon-colored.




screen_cast.mp4
313 KB View Download
Chrome.png
23.4 KB View Download
Firefox.png
19.9 KB View Download
testfile.html
90 bytes View Download
margins.png
13.9 KB View Download
Labels: -Pri-2 OS-Windows Pri-3
Status: Available (was: WontFix)
Summary: Clicking outside BODY element should make selection empty (was: Chrome creates selection without ranges when clicking outside of contenteditable.)
j.swiderski@, thanks for providing HTML in #c5. I could reproduce this.

I think click outside of <body> should make selection empty instead of keeping selection.

Sign in to add a comment