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

Suggestions not displaying #1415

Open
benguela opened this issue Oct 26, 2015 · 11 comments
Open

Suggestions not displaying #1415

benguela opened this issue Oct 26, 2015 · 11 comments

Comments

@benguela
Copy link

I have replicated the issue here
http://codepen.io/benguela/pen/epMMyo

In the field enter the letters

sco

bloodhound fetches suggestions but they are not displayed. if however you enter

scot

bloodhound fetches suggestions and they are displayed.
I have a workaround at the moment where in line 1724 of the typeahead bundle I changed

that._append(query, suggestions.slice(0, that.limit - rendered));

to

that._append(query, suggestions.slice(0, that.limit));

but this is not the correct solution.

@davidkallesen
Copy link

I have the same issue.. looking forward for a correct solution.

@pew007
Copy link

pew007 commented Oct 26, 2015

moved

rendered += suggestions.length; 

to after the append

that._append(query, suggestions.slice(0, that.limit - rendered));

and it appears to work

function async(suggestions) {
                    suggestions = suggestions || [];
                    if (!canceled && rendered < that.limit) {
                        that.cancel = $.noop;
                        that._append(query, suggestions.slice(0, that.limit - rendered));
                        rendered += suggestions.length;
                        that.async && that.trigger("asyncReceived", query);
                    }
                }

@benguela
Copy link
Author

@pew007 that worked, I updated my codepen to include my typeahead lib, I made that change and tested it.

Many thanks.

@aholland
Copy link

I've just fixed this same bug myself and have already submitted a pull request. It's because of the way that Array.slice interprets a positive "end" parameter. Here is the pull request. Until the request is merged, feel free to download copies from my branch. #1416

@amoerie
Copy link

amoerie commented Oct 27, 2015

+1, encountered this bug just now too.

@varunet
Copy link

varunet commented Nov 6, 2015

+1, same issue can be replicated here
http://jsfiddle.net/varunet/4vk43jpp/

Either of the fix works for me

  1. moving rendered line below that._append
that._append(query, suggestions.slice(0, that.limit - rendered));
rendered += suggestions.length;

or
2. modifying that._append

that._append(query, suggestions.slice(0, that.limit));

Currently, I will be moving on with option 1 for fix. Hope this gets fixed in next release.

@karlhorky
Copy link

This is fixed in the latest version of the corejavascript fork. You can install the latest commit with bower using:

bower install --save corejavascript/typeahead.js#6da45f53a74322f1c2a1cac60a1f6b1fd6914da0

nimzco added a commit to nimzco/typeahead.js that referenced this issue Dec 18, 2015
@nimzco
Copy link

nimzco commented Dec 18, 2015

@jharding https://github.com/twitter/typeahead.js/blame/master/src/typeahead/dataset.js#L272
I FOUND YOU!!! When will this be merged? :)

Here's a PR: #1449

@gakimball
Copy link

@karlhorky Thanks for the link! The Foundation framework's documentation uses Typeahead and we've needed this fix :)

@jlbooker
Copy link
Contributor

Duplicate of #1232

@picocodes
Copy link

So sad that this bug still exists today. 👎

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

No branches or pull requests