Opened 9 years ago

Closed 9 years ago

#16772 closed enhancement (patchwelcome)

Select: make clicking label focus widget

Reported by: ben hockey Owned by: Douglas Hays
Priority: undecided Milestone: future
Component: Dijit - Form Version: 1.8.3
Keywords: Cc:
Blocked By: Blocking:


looking at if you click the first label for a native select ("Four options:") you can see that the native select gets focused. the same does not work when you click the label for the first dijit/form/Select ("Test One:")

Change History (8)

comment:1 Changed 9 years ago by bill

Summary: dijit/form/Select doesn't work with labels the way native selects doSelect: make clicking label focus widget
Type: defectenhancement

I don't think clicking the label works for any of our widgets (ComboBox, DateTextBox, etc.). It could be done on widget startup() or in the parser, but not sure if the performance penalty is worth it. Seems like doing it on startup would be an O(n²) operation.

Is there a point to that feature that I'm missing? It seems just as easy to click the select directly as to click the label.

Last edited 9 years ago by bill (previous) (diff)

comment:2 Changed 9 years ago by Douglas Hays

Milestone: tbdfuture
Resolution: patchwelcome
Status: newclosed

Patches (especially those that don't search the entire DOM for associated label tags) are always appreciated. The Select widget is not natively a SELECT tag under the covers so the function would have to be emulated.

comment:3 Changed 9 years ago by ben hockey

Resolution: patchwelcome
Status: closedreopened

i just checked in chrome and it works for FilteringSelect? (see, ComboBox?, CheckBox?, RadioButton?, DateTextBox?, MultiSelect?, SimpleTextarea?, NumberSpinner?, Textarea, i didn't look beyond these.

i just thought it was an oversight that it doesn't work for Select.

comment:4 Changed 9 years ago by Douglas Hays

It's not an oversight. FilteringSelect uses a native INPUT so it natively works. Select is a collection of DIV/SPAN elements that cannot be not natively associated with LABEL.

comment:5 Changed 9 years ago by dylan

@doug: So, if there was no legacy history here, what would be the right solution for this?

@bill: All modern web browser support this capability for native widgets, so that you don't have to click precisely on an item... it's a common usability paradigm.

comment:6 Changed 9 years ago by Douglas Hays

I think the best solution is to change Select to use a native button element in 2.0. In that case, clicking the label would send a click event to the new widget's button node, and not a vanilla focus event like is sent with a native select element. This isn't exactly desired so we'd have to figure out how to fake things out a little. That's why I didn't mark it 2.0 since it might not work at all. I think this falls into the patchwelcome category.

comment:7 Changed 9 years ago by bill

That sounds like a good solution to me... I agree the behavior would be a little bit different than native selects, in that (IIUC) clicking the label would open the Select rather than just focusing it, but at least it wouldn't automatically select one of the options, so its not too bad.

comment:8 Changed 9 years ago by ben hockey

Resolution: patchwelcome
Status: reopenedclosed

ok, if it's not an oversight or a simple matter of assigning the id to an appropriate node then no problem, i've got yet another reason to prefer FilteringSelect? to Select whenever possible.

i just couldn't find anywhere where this had been talked about before - admittedly searching trac is not always fruitful - so i didn't know why Select didn't work with labels and thought i should bring it up.

Note: See TracTickets for help on using tickets.