Opened 13 years ago

Closed 12 years ago

Last modified 12 years ago

#8187 closed enhancement (fixed)

option for TextBox based widgets to auto select the text when first clicked.

Reported by: Scott Lewis Owned by: Douglas Hays
Priority: high Milestone: 1.4
Component: Dijit - LnF Version: 1.2.1
Keywords: Cc:
Blocked By: Blocking:


When the user clicks in the input field initially, all of the text in that field should be selected automatically so that the user can just start typing.

Attachments (1)

8187.patch (2.9 KB) - added by Douglas Hays 12 years ago.
patch file implementing selectOnFocus boolean attribute (default false) for all TextBox? widgets

Download all attachments as: .zip

Change History (18)

comment:1 Changed 13 years ago by bill

Milestone: tbd1.4

comment:2 Changed 13 years ago by Douglas Hays

I don't understand this request. This is not the native text box behavior (I tested on FF3 and IE7) nor is this the behavior with other dijit TextBox? classes.

comment:3 Changed 13 years ago by Scott Lewis

This is about the combo box and not TextBox?. Look at the second demo on The point is to save the user having to select the text "California" when he simply wants to click in the field and start typing "ill" when trying to quickly select Illinois.

comment:4 Changed 13 years ago by bill

Scott - ComboBox, TextBox, and native <input>'s are quite similar from a user's point of view. I see what you are asking for, but can you justify making ComboBox behave differently than a native <input> or a dijit TextBox?

See the first example in and how clicking the native input does not select the text. See also test_validate.html to see how dijit's other TextBox widgets don't select the text by clicking.

comment:5 Changed 13 years ago by Scott Lewis

Bill, I disagree with your premise. The user types partial strings in a combo box in order to select and in a text field in order to provide a complete string of input. Therefore the having them operate the same is not important.

If you look at flex's combobutton, they actually select the text in the box when the user hits the dropdown; not a bad idea (however they don't scroll appropriately when the user starts typing (at least in the example I saw)). I see this enhancement to the dojo combobox as an opportunity to beat flex's combobox.

If you can't see your way to making this a default behavior, then at least consider offering the developer the option to activate it.

comment:6 Changed 13 years ago by bill

Actually I think you are misunderstanding ComboBox by confusing it with FilteringSelect. Users often type full strings into a ComboBox. The drop down is only a list of suggestions, like on google suggests.

comment:7 Changed 13 years ago by Scott Lewis

Bill, Thanks for bringing up FilteringSelect?. I'll quote from the ComboBox? description: "The ComboBox? is a hybrid between a SELECT combo box and a text field. Like a SELECT, you provide a list of acceptable values. Unlike SELECT, and like a text box, the user can ignore all the choices and type whatever they want."

I assume by "SELECT combo box", it's referring to FilteringSelect? right (or maybe html native <select>?

So, ComboBox? and Filtering select share the goal of allowing the user to quickly select from a list of acceptable values with the ComboBox? adding the ability to accept new values.

Both FilteringSelect? and ComboBox? should have the behavior I'm suggesting. FilteringSelect? is the worse case. Why, if the user is not allowed to specify new values, does the widget not simply highlight the existing value in the text box or upon clicking the drop button (as in FLEX) so the user can simply start typing? As it stands, if the user simply starts typing, the input appears at the end of the current selection, is instantly validated and a warning appears: not good.

BTW, how do I enter defect against the website? The second example on the combobox page seems to use a filtering select as the second example of a combo box. Also, it refers to a "SELECT combo box" widget which (I assume means FilteringSelect? or maybe the native <select>?) Similarly, on the filtering select page there are some points of confusion.

comment:8 Changed 13 years ago by globex

I think there should be an option to activate this for all dijit.form fields. Because I would like a bunch of my form fields to behave like this too, but since it's not a native behavior, dojo should support it as an optional attribute.

comment:9 Changed 13 years ago by bill

I'd be more amenable to that, for the consistency.

comment:10 Changed 12 years ago by Douglas Hays

Owner: set to Douglas Hays
Status: newassigned

Changed 12 years ago by Douglas Hays

Attachment: 8187.patch added

patch file implementing selectOnFocus boolean attribute (default false) for all TextBox? widgets

comment:11 Changed 12 years ago by Douglas Hays

Bill, do you approve of this enhancement?

comment:12 Changed 12 years ago by Douglas Hays

The "save file as" dialog on windows works just like a combobox. The entire text selects on both mouse click and tab-to-focus. It seems like tab-to-focus always selects, and the mouse optionally selects (selectOnMouseFocus?). Currently the textbox widgets do not know which event caused the focus.

comment:13 Changed 12 years ago by Douglas Hays

Resolution: fixed
Status: assignedclosed

(In [20008]) Fixes #8187. Add selectOnClick boolean (default false) to TextBox? (and subclasses) that selects all text when the textbox is focused with a mouse click. Selecting text manually with the mouse will focus the textbox but will not trigger the select-all behavior. Added examples in a few tests.

comment:14 Changed 12 years ago by bill

Resolution: fixed
Status: closedreopened

Hi Doug,

After [20008] I'm getting test failures in robot/test_validate.html on safari (both mac and windows). It ends up showing multiple fields as being simultaneously focused (ie, having the blue border), and all (or most of) the text that's supposed to go to various fields ends up in the first ("First Name") field.

comment:15 Changed 12 years ago by Douglas Hays

Resolution: fixed
Status: reopenedclosed

(In [20146]) Fixes #8187. Restrict deselect on blur to Mozilla browsers.

comment:16 Changed 12 years ago by bill

[In [20920]) Rework selectOnClick code to get it working again. The trick is getting it to only select all the text on the first click. (Otherwise there would be no way to deselect the text.)

Since mousedown on a blurred field focuses it, it's tricky timing detecting when the mousedown causes focus versus when the field was already focused. (Plus detecting when a focus event was caused by tabbing into the field.) Note that the order of onmousedown and onfocus varies between IE and FF.

Seems possible to detect it though, in focus.js, after [20662]. So added a flag to _onFocus() callback that tells whether focus was caused by mousedown ("mouse") or not. (Using a string flag for possible future expansion via touch events etc.)

Fixes #10417, refs #10208, #8187 !strict.

comment:17 Changed 12 years ago by bill

Summary: ComboBox - Should auto select the text when clicked.option for TextBox based widgets to auto select the text when first clicked.
Type: defectenhancement

Updating ticket summary since with what we ended up implementing (as opposed to the original request from Scott, to make it the default behavior for ComboBox and FilteringSelect)

Note: See TracTickets for help on using tickets.