New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 714425 link

Starred by 18 users

Issue metadata

Status: Fixed
Owner:
Closed: May 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 1
Type: Bug-Regression



Sign in to add a comment

selection{Start,End} of TEXTAREA and INPUT are wrong after blur

Reported by huglovef...@gmail.com, Apr 23 2017

Issue description

UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3013.0 Safari/537.36

Example URL:

Steps to reproduce the problem:
1. Open the attached html file.
2. Type "test" in the text area, then hit enter twice (to input two newlines.)
3. (At this point, the selectionStart and selectionEnd numbers should both be 6.)
4. Click outside of the textarea.

What is the expected behavior?
The selection numbers should stay the same.

What went wrong?
Both the selection numbers change to 5, until you click the textarea again.

Does it occur on multiple sites: Yes

Is it a problem with a plugin? No 

Did this work before? Yes 

Does this work in other browsers? Yes

Chrome version: 58.0.3013.0  Channel: n/a
OS Version: 10.0
Flash Version: 

last version with correct behavior:
Chromium 58.0.3013.0 (Developer Build) (64-bit)
Revision 679ec32b1ab9d0fe56cfec0642b7cadffc815beb-refs/heads/master@{#450368}

first version with incorrect behavior:
Chromium 58.0.3013.0 (Developer Build) (64-bit)
Revision 6396f2506e7fa1793a7223f2a1a191fb1316f56e-refs/heads/master@{#450379}

there's this commit in between that looks related:
https://chromium.googlesource.com/chromium/src/+/d892f9592860691ae9a782c12260c94ed6bd1a63
 
bug.html
421 bytes View Download

Comment 1 by tkent@chromium.org, Apr 24 2017

Components: -Blink Blink>Forms>Textarea Blink>Editing>Selection
Labels: -Type-Bug -Pri-2 M-59 ReleaseBlock-Stable Pri-1 Type-Bug-Regression
Owner: yosin@chromium.org
Status: Assigned (was: Unconfirmed)
Cc: pbomm...@chromium.org ligim...@chromium.org
Labels: M-60 M-58 OS-Linux OS-Mac
Thank you  huglovefan1998@, Sorry for rebisecting to make sure we are pointing to right Cl and you are spot one. Please find the bisect below :

You are probably looking for a change made after 450369 (known good), but no lat
er than 450370 (first known bad).
CHANGELOG URL:
  https://chromium.googlesource.com/chromium/src/+log/18375370aff250f59f5ef624ecf686d860377ece..d892f9592860691ae9a782c12260c94ed6bd1a63


issue is reproducible on Windows 7,10, Mac and Linux on latest Chrome Dev, Canary and Stable, Since it's Blink related change tagging Android and ChromeOS 


Labels: OS-Android OS-Chrome
As 58 is already in stable for these browser platforms, should this really have a ReleaseBlock-Stable label?

We are looking to qualify a Chrome OS stable build tomorrow, so we need to determine quickly the severity of this issue.

Comment 5 by tkent@chromium.org, Apr 26 2017

Labels: -M-58 -M-60
#4, I don't think this is a M58 stable blocker.

Comment 6 by yosin@chromium.org, Apr 27 2017

Labels: -M-59

Comment 7 by yosin@chromium.org, Apr 27 2017

Labels: M-59
Status: Available (was: Assigned)

Comment 8 by yosin@chromium.org, Apr 27 2017

Owner: ----
Labels: -OS-Linux -OS-Android -OS-Windows -Pri-1 -Arch-x86_64 -OS-Chrome -ReleaseBlock-Stable -OS-Mac -M-59 OS-All Pri-2
Reproduced.
This happens when we have:
 1. 2 line breaks on the end of textarea.
 2. Cursor is on the end.
 3. Focus out with mouse/tab.
Then selectionStart/End point after first line break.



Comment 10 by tkent@chromium.org, Apr 28 2017

 Issue 716327  has been merged into this issue.
Summary: selection{Start,End} of TEXTAREA and INPUT are wrong after blur (was: case where textarea selection{Start,End} are wrong)
This issue can be triggered in another way:
Copy "test\n" to your clipboard.
Now load the test case from the original bug report and focus the textarea and paste it n times using Ctrl-V with n>=2. selectionStart/selectionEnd will now be n*5, which is to be expected.
Now unfocus the textarea by clicking outside of it or pressing tab. It will now show "selectionStart: 5, selectionEnd: 5", which is wrong.

After you followed the steps above, put the focus back on the textarea.
Now press Ctrl-A (or select the whole textarea using your mouse). Now press backspace or delete (this step is important, otherwise it will show 5 again). Press Ctrl-V n times (n>=2). Unfocus the textarea. It will now show "selectionStart: 0, selectionEnd: 0", which is also wrong (but with a different value for some reason).

In any case (including the steps from the original bug report), selectionStart/End stay correct if:
- you click with the mouse on the current cursor position before unfocusing.
- you temporarily change the cursor position e.g. by pressing left and then right arrow key before unfocusing.

Note that this issue does not only affect the selectionStart/End JavaScript properties, but when focusing the textarea by pressing tab again, the cursor will be at the wrong position (the same position as denoted by the JS properties).

Using "Version 58.0.3029.81 Built on Ubuntu , running on Ubuntu 14.04 (64-bit)".
Owner: tkent@chromium.org
Status: Assigned (was: Available)
selectionStart and selectionEnd is updated internally by 'selectionchange' event.  It seems that 'selectionchange' event is not dispatched by Enter key, Backspace key, and paste operation.

Comment 14 by tkent@chromium.org, May 11 2017

Labels: -Pri-2 M-59 Pri-1
Status: Started (was: Assigned)

Comment 15 Deleted

Comment 16 by yosin@chromium.org, May 12 2017

Does fix for this issue also fix  issue 503132 ?

Comment 17 by tkent@chromium.org, May 12 2017

> It seems that 'selectionchange' event is not dispatched by Enter key, Backspace key, and paste operation.

Because editing Text nodes in a text control are split at the caret position, and DOM representation of the position is not changed.

> Does fix for this issue also fix   issue 503132  ?

I'm not sure what it is.

Project Member

Comment 18 by bugdroid1@chromium.org, May 12 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/e71aa45ab3098edca75725a658d3624f5ed47108

commit e71aa45ab3098edca75725a658d3624f5ed47108
Author: tkent <tkent@chromium.org>
Date: Fri May 12 12:59:21 2017

INPUT/TEXTAREA elements: Fix incorrect selectionStart/selectionEnd values after blur.

We failed to update selectionStart/selectionEnd cache because
TextControlElement::SelectionChanged() is not called in some cases after
crrev.com/450370.

After this CL, selection values are cached in webkitEditableContentChanged event
handling code too.  It is called on every DOM mutation in text control editor.

BUG= 714425 

Review-Url: https://codereview.chromium.org/2878613002
Cr-Commit-Position: refs/heads/master@{#471290}

[add] https://crrev.com/e71aa45ab3098edca75725a658d3624f5ed47108/third_party/WebKit/LayoutTests/fast/forms/text-control-selection-after-blur.html
[add] https://crrev.com/e71aa45ab3098edca75725a658d3624f5ed47108/third_party/WebKit/LayoutTests/fast/forms/text/text-selection-after-type-change.html
[modify] https://crrev.com/e71aa45ab3098edca75725a658d3624f5ed47108/third_party/WebKit/Source/core/html/TextControlElement.cpp

Comment 19 by tkent@chromium.org, May 14 2017

Status: Fixed (was: Started)

Comment 20 by tkent@chromium.org, May 14 2017

Labels: ReleaseBlock-Stable Merge-Request-59
Project Member

Comment 21 by sheriffbot@chromium.org, May 14 2017

Labels: -Merge-Request-59 Hotlist-Merge-Approved Merge-Approved-59
Your change meets the bar and is auto-approved for M59. Please go ahead and merge the CL to branch 3071 manually. Please contact milestone owner if you have questions.
Owners: amineer@(Android), cmasso@(iOS), gkihumba@(ChromeOS), Abdul Syed@(Desktop)

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Please merge your change to M59 branch 3071 by 4:00 PM PT, Monday (05/15) so we can take it in for next week beta release. Thank you.
Project Member

Comment 23 by bugdroid1@chromium.org, May 15 2017

Labels: -merge-approved-59 merge-merged-3071
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/e05011e0add858f12cb6f90cc534415870d9f7af

commit e05011e0add858f12cb6f90cc534415870d9f7af
Author: Kent Tamura <tkent@chromium.org>
Date: Mon May 15 05:56:31 2017

Merge "INPUT/TEXTAREA elements: Fix incorrect selectionStart/selectionEnd values after blur." to M59

We failed to update selectionStart/selectionEnd cache because
TextControlElement::SelectionChanged() is not called in some cases after
crrev.com/450370.

After this CL, selection values are cached in webkitEditableContentChanged event
handling code too.  It is called on every DOM mutation in text control editor.

BUG= 714425 

Review-Url: https://codereview.chromium.org/2878613002
Cr-Original-Commit-Position: refs/heads/master@{#471290}
Review-Url: https://codereview.chromium.org/2882953002 .
Cr-Commit-Position: refs/branch-heads/3071@{#549}
Cr-Branched-From: a106f0abbf69dad349d4aaf4bcc4f5d376dd2377-refs/heads/master@{#464641}

[add] https://crrev.com/e05011e0add858f12cb6f90cc534415870d9f7af/third_party/WebKit/LayoutTests/fast/forms/text-control-selection-after-blur.html
[add] https://crrev.com/e05011e0add858f12cb6f90cc534415870d9f7af/third_party/WebKit/LayoutTests/fast/forms/text/text-selection-after-type-change.html
[modify] https://crrev.com/e05011e0add858f12cb6f90cc534415870d9f7af/third_party/WebKit/Source/core/html/TextControlElement.cpp

Comment 24 by tkent@chromium.org, May 17 2017

Cc: kavvaru@chromium.org tkent@chromium.org
 Issue 721733  has been merged into this issue.
Labels: TE-Verified-M59 TE-Verified-59.0.3071.61
Verified this issue on Mac OS 10.12, Ubuntu 14.04 and Windows-10 using chrome latest beta M59-59.0.3071.61 by following steps mentioned in the original comment. After step-4 observed the selection number stays same as expected. Hence adding TE-Verified label.
714425.ogv
939 KB View Download

Comment 26 by tkent@chromium.org, May 19 2017

 Issue 724403  has been merged into this issue.

Comment 27 by tkent@chromium.org, May 22 2017

 Issue 725139  has been merged into this issue.

Comment 28 by tkent@chromium.org, May 30 2017

 Issue 727199  has been merged into this issue.

Comment 29 by yosin@chromium.org, May 30 2017

Cc: hdodda@chromium.org
 Issue 726333  has been merged into this issue.
 Issue 730942  has been merged into this issue.

Comment 31 by tkent@chromium.org, Jun 18 2017

 Issue 734428  has been merged into this issue.

Sign in to add a comment