Option for Automatic selection of the first item in the typeahead resultset
Would it be possible for there to be an option for the first item to be automatically selected in the typeahead on search so a press of the enter key will go to that specific item's url? This would save the user needing to press the downarrow key to get to that first item and then pressing the enter key. Thanks!
I don't know if we'll ever add anything like this as I think this behavior would be potentially confusing to the end-user. You may be able to implement this behavior after v0.9 is released, but it'd be based on custom events and not a configurable option.
Thanks for responding on this! Some of the bigger websites (eg facebook) use this, and jQuery UI autocomplete has this as an option as well. Looks like i'll have to play around with typeface v.9+.
I agree with jharding, but in some case it could be great to have the option. ie: when the user typed his query and there is only one item left in the list. The user still have to select the line (most basic user don't really use tab)
A use case I need to support is to have a generic "Search for < typed input >" entry as the first item. It would make sense that this item is selected by default.
I outlined a workaround in #142. Also, see #141 for adding the generic "Search for" entry.
+1
If you're interested, I implemented this in a fork.
https://github.com/nagiek/typeahead.js
:+1: for an option
:+1:
+1
+1
@nagiek Hi, please where exactly is it implemented?
No ETA, this isn't very high priority for me. I would consider accepting a pull request for this issue though.
We added functionality to typeahead on our own. https://github.com/UrbanCompass/typeahead.js
We use it like:
searchBox.typeahead({
name: 'neighborhoods',
local: neighborhoods,
minLength: 0,
limit: Infinity
})
But our version is no where near pull-request quality.
What would be a good name for this option?
autoselect: 'first'
Sjlu,
Both your auto-selecting the first option and the allowing minLength of 0 look really useful.
I would love to see a pull request for both.
It's very hacky, we'll make it a little more beautiful then submit a pull request.
Just need time to do so ;)
You may not have to submit a pull request as an autoselect option has been added to v0.10 and I also added the ability to render default suggestions, although not by using minLength: 0.
+1