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.
I have the same issue.. looking forward for a correct solution.
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);
}
}
@pew007 that worked, I updated my codepen to include my typeahead lib, I made that change and tested it.
Many thanks.
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. https://github.com/twitter/typeahead.js/pull/1416
+1, encountered this bug just now too.
+1, same issue can be replicated here
http://jsfiddle.net/varunet/4vk43jpp/
Either of the fix works for me
that._append(query, suggestions.slice(0, that.limit - rendered));
rendered += suggestions.length;
or
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.
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
@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: https://github.com/twitter/typeahead.js/pull/1449
@karlhorky Thanks for the link! The Foundation framework's documentation uses Typeahead and we've needed this fix :)
Duplicate of #1232
So sad that this bug still exists today. :-1:
Most helpful comment
So sad that this bug still exists today. :-1: