New issue
Advanced search Search tips

Issue 730942 link

Starred by 1 user

Issue metadata

Status: Duplicate
Merged: issue 714425
Owner:
Closed: Jun 2017
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 2
Type: Bug-Regression



Sign in to add a comment

selectionStart/selectionEnd returns wrong data when blurred after backspace

Reported by sunderls...@gmail.com, Jun 8 2017

Issue description

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

Steps to reproduce the problem:
1.  
open chrome v58

access this jsfiddle : https://jsfiddle.net/56Lxoznp/3/
or open following html

<!DOCTYPE html>
<html>
<head>
</head>
<body>
<textarea id='input'></textarea>
<script>
var input = document.getElementById('input');

input.addEventListener('blur', function(){
    console.log('selection on blur [ ' + input.selectionStart + ' ~ ' + input.selectionEnd + ' ]');
}, false);

input.addEventListener('keyup', function(){
    console.log('selection on keyup [ ' + input.selectionStart + ' ~ ' + input.selectionEnd + ' ]');
}, false);
</script>
</body>
</html>

2.  open chrome devltool, enter "12345" in the input,
you should see following logs:

selection on keyup [ 1 ~ 1]
selection on keyup [ 2 ~ 2]
selection on keyup [ 3 ~ 3]
selection on keyup [ 4 ~ 4]
selection on keyup [ 5 ~ 5]

3.  now move cursor back for one step( from `12345|` to `1234 | 5`)

selection on keyup [ 4 ~ 4]

4. press backspace, delete `4`,  ( now `123|5` )

selection on keyup [ 3 ~ 3]

5. click outside of textarea, you should see a new log

selection on blur [ 4 ~ 4]

What is the expected behavior?
one step 5, I think it should return the same selectionStart/End with step 4,
which means on blur event, selectionStart/End should be the same as focused

This leads to problems, when we are building some widget for inserting contents into input elements, since it returns wrong positions.

What went wrong?
I don' know..

Did this work before? Yes Chrome 56  ( I think)

Does this work in other browsers? Yes

Chrome version: 58.0.3029.110  Channel: n/a
OS Version: OS X 10.10.5
Flash Version:
 

Comment 1 by tkent@chromium.org, Jun 8 2017

Mergedinto: 714425
Owner: tkent@chromium.org
Status: Duplicate (was: Unconfirmed)
Please try the latest Google Chrome stable.  It's 59.0.3071.*.

oh ....thanks for letting me know...

Sign in to add a comment