New issue
Advanced search Search tips

Issue 721217 link

Starred by 5 users

Issue metadata

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



Sign in to add a comment

INPUT selectionStart/selectionEnd return wrong values just after type change

Project Member Reported by tkent@chromium.org, May 11 2017

Issue description

Chrome Version: 60 canary
OS: All

What steps will reproduce the problem?
(1) Load a page like:

<input>
<script>
document.querySelector('input').addEventListener('keypress', function (e) {
  if (e.key == 't') {
    if (e.target.type == 'text') {
      e.target.type = 'button';
      e.target.type = 'text';
      console.log(e.target.selectionStart);
    }
  }
});
</script>

(2) Open DevTools console.
(3) Click on the INPUT field, then type 'foot'.

What is the expected result?
The console shows "3", which is the length of 'foo'.

What happens instead?
The console shows "0".

Please use labels and text to provide additional information.

HTMLTInputElement::UpdateType():

  // UA Shadow tree was recreated. We need to set selection again. We do it
  // later in order to avoid force layout.
  if (GetDocument().FocusedElement() == this)
    GetDocument().UpdateFocusAppearanceLater();

So the INPUT element doesn't return correct selection values until UpdateFocusAppearance() is called.

 

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

Summary: INPUT selectionStart/selectionEnd return wrong values just after type change (was: INPUT selectionStart/selectionEnd return wont values just after type change)
Project Member

Comment 2 by sheriffbot@chromium.org, May 14 2018

Labels: Hotlist-Recharge-Cold
Status: Untriaged (was: Available)
This issue has been Available for over a year. If it's no longer important or seems unlikely to be fixed, please consider closing it out. If it is important, please re-triage the issue.

Sorry for the inconvenience if the bug really should have been left as Available.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot

Comment 3 by tkent@chromium.org, May 15 2018

Labels: -Hotlist-Recharge-Cold
Status: Available (was: Untriaged)

Sign in to add a comment