[Bug 12271] <input list=""> needs an event triggered on selection of suggestion

http://www.w3.org/Bugs/Public/show_bug.cgi?id=12271

--- Comment #3 from Jonas Sicking <jonas@sicking.cc> 2011-03-22 20:55:30 UTC ---
> First off, maybe there's a misunderstanding. When I say "selection" /
> "onListSelect", I mean that the user explicitly clicked on an entry with the
> mouse, or he pressed Enter, Return or Space with the keyboard. I do *not* mean
> that another list entry is highlighted after a mere mouse hover or keyboard
> cursor keys.

Yes, I assumed that. Not sure what indicated otherwise?

> > But I'm not sure how adding an onListSelect helps here?
> 
> If label = "Arthur Dosh", value = "art@example.net", the dropdown display would
> be fine (in this case). Opon selection, my code takes label + " <" + value +
> ">" and fills that into the textfield, possibly appending ", ", too.
> 
> More generally, the value that I fill in may not have anything to do with what
> I show to the user in the dropdown and what I autocomplete to.

So just do
<input type=text list=mylist multiple>
<datalist>
  <option label="Arthur Dosh" value="Arthur Dosh <art@example.net>">
  ...
</datalist>

> Another usecase: for database frontends, I may want to show only the name of
> the person, but fill in the database ID. The user should never see the
> database  ID, but the ID is what my app actually uses. The user should be
> able to type to autocomplete to the name. (I am not sure the input list or
> any other HTML5 widget covers this usecase well, but this proposal here would
> be a start.)

This doesn't sound like a <input> element at all since I'm assuming you don't
want the user to be able to type arbitrary values, but rather just select from
a list. I.e. the user should only be able to select valid IDs, right?

This sounds much more similar to a <select multiple>. Unfortunately the UI for
those are pretty terrible right now. In part this UI is forced upon browsers
since if they tried to change it web authors would likely throw a fit since
existing pages would change so dramatically.

Maybe we could add some attribute to <select> which would opt in to a better UI
somehow.

-- 
Configure bugmail: http://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

Received on Tuesday, 22 March 2011 20:55:33 UTC