Bug 8743 - REGRESSION: focus() on input field selects all text within it (was: cannot select cities on British Rail reservation site)
Summary: REGRESSION: focus() on input field selects all text within it (was: cannot se...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Forms (show other bugs)
Version: 420+
Hardware: Mac OS X 10.4
: P1 Normal
Assignee: Darin Adler
URL: http://www.britishrail.com/timetable_...
Keywords: EasyFix, Regression
Depends on:
Blocks:
 
Reported: 2006-05-04 15:19 PDT by Hanspeter Schaub
Modified: 2006-05-11 10:42 PDT (History)
2 users (show)

See Also:


Attachments
Test case (602 bytes, text/html)
2006-05-05 11:33 PDT, jonathanjohnsson
no flags Details
patch (937 bytes, patch)
2006-05-09 22:54 PDT, Darin Adler
adele: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Hanspeter Schaub 2006-05-04 15:19:56 PDT
REGRESSION

On the British Rail reservation system I can no longer select cities in the departure/arrival text fields.  As you start typing a city name there, the web page provides you with all possible cities that match your letters types.  However, with the latest safari build (5/4/06) the latest letter typed is always used as the first letter?  

In the regular version of Safari that comes with 10.4.6 this does not occur.  Here if you start typing a city, after each letter your possible selections are reduced until you select a specific city.
Comment 1 jonathanjohnsson 2006-05-05 11:33:57 PDT
Created attachment 8126 [details]
Test case

When the Javascript function focus() is run on an input field, it not only focuses the field, but selects all the text. This regression happened between nightlies r13568 and r13574.
Comment 2 Darin Adler 2006-05-06 12:00:29 PDT
What is focus() supposed to do, selection-wise? What does it do in other browsers? Is the selection supposed to go at the end of the field?
Comment 3 Darin Adler 2006-05-09 09:15:14 PDT
I think the issue is only when focus() is called on a field that's already focused. I'm guessing the behavior of selecting all is fine when the field doesn't already have focus.

The problem is in HTMLInputElement::focus, which calls select() unconditionally and instead should call it only if the focus node is not already set.
Comment 4 Darin Adler 2006-05-09 22:54:30 PDT
Created attachment 8198 [details]
patch
Comment 5 Adele Peterson 2006-05-10 00:41:41 PDT
Comment on attachment 8198 [details]
patch

I think the AppKit controls maintain some state for their selection.  In the future, we want to restore some of that state when we focus.
Comment 6 Darin Adler 2006-05-11 10:42:35 PDT
Committed revision 14301.