New issue
Advanced search Search tips

Issue 915231 link

Starred by 1 user

Issue metadata

Status: Duplicate
Merged: issue 919540
Owner: ----
Closed: Jan 10
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 2
Type: Bug



Sign in to add a comment

Textarea selectionStart and selectionEnd props don't ALWAYS updated by the time the click handler is fired

Reported by sharon...@gmail.com, Dec 14

Issue description

UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:65.0) Gecko/20100101 Firefox/65.0

Steps to reproduce the problem:
1. Double click on any word to select it.
2. Once the word is selected, single left click on it again, to deselect it.
Now the caret is flashing somewhere inside the previously selected word.

What is the expected behavior?
I expected that by the time the click handler was called the selectionStart and selectionEnd properties had been already updated.

What went wrong?
Even though that visually the selection was replaced with a flashing caret, the selectionStart and selectionEnd properties still belonged to the previous selection when the click hanlder was called. However it got updated eventually: if you move the mouse out from the textarea in the attached example, you see the updated value.

Did this work before? N/A 

Does this work in other browsers? N/A

Chrome version: 73.0.3639.1 (Official Build) canary (32-bit) (cohort: Clang-32)  Channel: canary
OS Version: 10.0
Flash Version: 32.0.0.105

When I click any other word but the selected one, both the selectionStart and selectionEnd properties update by the time the click hanlder is called.

Firefox updates the properties by the time the click event hanlder is called irrecpective to what was selected before.

In Edge, clicking on a selected word sets both selectionStart and selectionEnd to zero. Clicking on an unselected word, the selection properties updates correctly by the time the click hanlder is called.
 
textarea-selection-click.html
1.5 KB View Download
I was experimenting with setting passive to true for the click handler, and forgot to change it back in the example I attached. Sorry for that. Having it set to passive does not modify the outcome anyway.
Labels: Needs-Triage-M73
Components: -Blink>Forms Blink>Editing>Selection
Labels: Hotlist-Interop
Status: Untriaged (was: Unconfirmed)
I confirmed this was reproducible with <div contenteditable=true>.
Firefox works as expected, that is to say, single click shows collapsed selection.

Mergedinto: 919540
Status: Duplicate (was: Untriaged)
Since Chrome sets selection after dispatching focus event, selection{Start,End} hold previous value.

We track this issue by 919540

I think this issue is not a duplicate of 919540, since that one is talking about the focus event.

On that issue you wrote the following:

“* SelectionController::HandleMousePressEvent() -> **update selection then dispatch "click" event**”

So one can righly expect that by the time the click handler is called, the selection{Start,End} holds the new value.
Which is true most of the time, expect when there was a selection AND one clicks somewhere on that selection range.

I made a short screen recording to prove that the selection{Start,End} value had been not updated when the CLICK handlers were called. Also, this same issue affects the input element as well.
chrome-selection-error.mp4
6.5 MB View Download

Sign in to add a comment