Closed Bug 956530 Opened 7 years ago Closed 6 years ago

input.select() method not staying selected on multiple clicks

Categories

(Core :: DOM: Selection, defect)

26 Branch
x86_64
Windows 7
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla40
Tracking Status
firefox40 --- fixed

People

(Reporter: impressive.webs, Assigned: ehsan)

Details

(Keywords: testcase)

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36

Steps to reproduce:

Go to this page:

http://jsbin.com/iYOFErAW/1

Click in the text field. Then click outside the text field. Then click again inside the text field.


Actual results:

The first time the field is clicked into, the text is selected (highlighted via the select() method). The 2nd time you click into the field (after clicking outside the field, then back inside again) the text is momentarily selected, then it deselects.


Expected results:

The text should always be selected no matter how many times you click into the text field.

Other browser results:

- Google Chrome has the same bug on all clicks, even the first one.
- IE11 and Opera do not have this bug. They correctly select the text on each click.
FYI, I also wrote a blog post about this issue here:

http://www.impressivewebs.com/input-select-correct-behaviour/

There are brief screencasts showing each browser's behaviour.
Component: Untriaged → DOM: Core & HTML
Keywords: testcase
Product: Firefox → Core
That's .... pretty odd.  Ehsan, do you have time to take a look?
Component: DOM: Core & HTML → Selection
Flags: needinfo?(ehsan)
Yes, but it needs to wait until a weekend or something.  Taking.
Assignee: nobody → ehsan
What's happening here is that the second time that you click on the text box, we detect that you're clicking on a selection, and set the drag state to false here: <https://dxr.mozilla.org/mozilla-central/source/layout/generic/nsFrame.cpp#2952>, then in HandleRelease, we detect this case <https://dxr.mozilla.org/mozilla-central/source/layout/generic/nsFrame.cpp#3333> and we end up setting the position of the caret forcefully which results in the observed bug.  The reason why this bug happens every other time is that the odd times when you click on the text box, we get to this code <https://dxr.mozilla.org/mozilla-central/source/layout/generic/nsFrame.cpp#2958> which causes mouseDown to end up being true in HandleRelease.
Flags: needinfo?(ehsan)
https://hg.mozilla.org/mozilla-central/rev/a766b7f35efa
https://hg.mozilla.org/mozilla-central/rev/b0a131a21f05
Status: UNCONFIRMED → RESOLVED
Closed: 6 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla40
You need to log in before you can comment on or make changes to this bug.