Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request on 0.10: Add a class to the first suggestion if autoselect is true #483

Closed
chibicode opened this issue Oct 14, 2013 · 12 comments
Closed
Labels

Comments

@chibicode
Copy link
Contributor

Hi, thank you for this great plugin :) I've tried out the integration-0.10.0 branch and love the new APIs. I have one request on autoselect (related to #332 ): would it be possible to:

  • Add a tt-autoselect class to the tt-suggest element that will be autoselected, just like .tt-cursor.
  • But ensure that tt-autoselect is only applied when the user has not manually selected anything. In other words, if the user mouses over some other .tt-suggest element, then .tt-autoselect should be removed from the first element until the user selects nothing again.

This way, even if hint is false, I'll be able to use CSS to signal users which suggestion will be autoselected upon hitting enter.

Since the first element will always be auto-selected, I thought of using .tt-suggest:first-child in my CSS, but this doesn't work when there are more than one sections.

@jharding
Copy link
Contributor

Great point. Seeing as how v0.10 is about overdue by 5 or so months (my bad), I'm going to put this in the v0.10.1 milestone.

@chibicode
Copy link
Contributor Author

👍 Thank you!

@dsposito
Copy link

dsposito commented Jun 3, 2014

+1

It looks like this issue hasn't been assigned to a milestone. Any plans for this in the near-future?

@jharding
Copy link
Contributor

jharding commented Jul 9, 2014

I'm actually leaning towards removing the autoselect functionality, so to answer @dsposito's question, there are no plans for this in the near-future.

@marshals
Copy link

marshals commented Jul 9, 2014

Personally I'd hate to see it removed because my business people love/require autoselect.

@jharding
Copy link
Contributor

jharding commented Jul 9, 2014

Yeah, I'm torn on what I should do. On one hand, I think the current implementation is half-baked so I don't want to encourage people to use it. On the other hand, it's something a lot people seem to use, so there's clearly a need for the functionality. At the very least, I won't remove the current implementation until there's something to replace it with.

@simplenotezy
Copy link

There is defiantly a big need for this feature.

@legshooter
Copy link

Really missing this, if demand is of any importance here's my +1 cents.

@WillemStaels
Copy link

Change the getDatumForSuggestion function to this one below when using autocomplete to auto-select the first item.

getDatumForSuggestion: function getDatumForSuggestion($el) {
                var datum = null;
                if ($el.length) {
                    if(!this._getCursor().length){
                      this._setCursor(this._getSuggestions().first(),true);
                    }
                    datum = {
                        raw: Dataset.extractDatum($el),
                        value: Dataset.extractValue($el),
                        datasetName: Dataset.extractDatasetName($el)
                    };
                }
                return datum;
            },

@PierBover
Copy link

Can someone post an example on how to implement the getDatumForSuggestion function?

@galenwilk
Copy link

@PierBover just make sure you've enabled the autoselect: true option when initializing your typeahead. Then in the typeahead.js source replace the existing getDatumForSuggestion function with the one above.

@PierBover
Copy link

Ah thanks @galenwilk I thought the function was some callback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

9 participants