-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
typeahead not showing all results if less than limit #1232
Comments
+1. The problem seems to be on Dataset's update function... On the inner function called async. function async(suggestions) {
suggestions = suggestions || [];
if (!canceled && rendered < that.limit) {
that.cancel = $.noop;
rendered += suggestions.length;
that._append(query, suggestions.slice(0, that.limit - rendered)); // IMHO this slice shouldn't exist...
that.async && that.trigger("asyncReceived", query);
}
} |
Both PRs close the issue. #1212 comes with a test ;] |
This is solved in #1200 but it isn't in master |
Thx. I catched this. |
Can we expect this anytime soon? |
Thanks @rafaelGuerreiro. You just saved my day 👍 |
+1 for merging this |
+1 for merging |
+1 for merging this |
Interestingly, in my case no result is displayed when the number of suggestions exactly equals the limit I set. I use the three parameters async source function. |
This is a very nasty bug, looks like a patch has been out for almost three months ( merge #1212 ), but still hasn't been pulled into main. Considering the popularity of the project I hope they patch the issue soon. |
+1 @luanau, the same thing happens. Zero results are shown when limit is equal to number of suggestions, 1 result when limit is greater by one and so on. |
+1 @droghio, it's strange there is no new release yet. |
For anybody who wants a quick solution, just use |
@louy Thanks, that works perfectly and probably the right solution anyway, why return more results than you are going to display? Waste of network traffic |
it is, but you have to subtract results from |
I have just spent hours trying to work out what the f***k was going on here and just come across this. I'm assuming this still isn't fixed in 0.11.1 (the ver I'm using)? I had my limit set to 7. I'm returning no more than 7 results from the server. When the result set is e.g. 5, it's only showing the first 2 etc. |
I had the same problem and found the best option was to use a fork that already resolved this issue. |
@louy, but if one has no access to server configuration or using third-party API? @timkinnane, thanks, it's better than apply patch just in building process. |
I decided to go for the lazy option and just set limit to 400 (though based on my wanted limit of 7 I guess 14 would work just as well). |
👍 for merging |
+1 for merging |
+1 |
Could limit using Nth-Child in CSS as a workaround too. |
@louy Thank you for the |
This repo seems abandoned.. some kind souls continue maintaing it here: https://github.com/corejavascript/typeahead.js |
I've been using https://github.com/corejavascript/typeahead.js for a while now instead of this repo, and it works great. highly suggest migrating over there. |
I confirm too, this bug has still not been fixed. |
+1 for using Infinity and limiting on the backend. But nevertheless this should be patched on master. There's no one working on this repository anymore? |
@alestuber This repo is as dead as dead gets as far as I can tell. https://github.com/corejavascript/typeahead.js is the place to go. |
For Rails devs here, you can use this fork of the |
Also see the original typeahead.js issue twitter/typeahead.js#1232
I noticed while investigating a bug that the typeahead library is essentially abandoned: twitter/typeahead.js#1232 One of the comments in the above thread mentions this fork of the library, which is actively maintained and includes a fix for said bug.
Fixes #131, weird typeahead bug, read about it here twitter/typeahead.js#1232
When the server returns less suggestions than what is configured as limit for the autocompleter, it only shows the first one, not adding the others to the suggestions list. This is a bug detected in Typeahead library, see twitter/typeahead.js#1232. This library seems not to be actively maintained by Twitter anymore (latest commits were in 2015). I've taken the patch from a fork, Corejs Typeahead.js https://github.com/corejavascript/typeahead.js https://github.com/corejavascript/typeahead.js/blob/107a9b0d002e549be746d93a1fbcde05853d745a/src/typeahead/dataset.js#L269-L281
When the server returns less suggestions than what is configured as limit for the autocompleter, it only shows the first one, not adding the others to the suggestions list. This is a bug detected in Typeahead library, see twitter/typeahead.js#1232. This library seems not to be actively maintained by Twitter anymore (latest commits were in 2015). I've taken the patch from a fork, Corejs Typeahead.js https://github.com/corejavascript/typeahead.js https://github.com/corejavascript/typeahead.js/blob/107a9b0d002e549be746d93a1fbcde05853d745a/src/typeahead/dataset.js#L269-L281
Backport of geonetwork#3332. When the server returns less suggestions than what is configured as limit for the autocompleter, it only shows the first one, not adding the others to the suggestions list. This is a bug detected in Typeahead library, see twitter/typeahead.js#1232. This library seems not to be actively maintained by Twitter anymore (latest commits were in 2015). I've taken the patch from a fork, Corejs Typeahead.js https://github.com/corejavascript/typeahead.js https://github.com/corejavascript/typeahead.js/blob/107a9b0d002e549be746d93a1fbcde05853d745a/src/typeahead/dataset.js#L269-L281
) Backport of #3332. When the server returns less suggestions than what is configured as limit for the autocompleter, it only shows the first one, not adding the others to the suggestions list. This is a bug detected in Typeahead library, see twitter/typeahead.js#1232. This library seems not to be actively maintained by Twitter anymore (latest commits were in 2015). I've taken the patch from a fork, Corejs Typeahead.js https://github.com/corejavascript/typeahead.js https://github.com/corejavascript/typeahead.js/blob/107a9b0d002e549be746d93a1fbcde05853d745a/src/typeahead/dataset.js#L269-L281
|
I'm using typeahead with the following code:
Where 'questionsList' is a Bloodhound instance. The suggestions seem to be working fine when the query's number of matches is greater than 'limit' (10 in this case). But the problem is when the number of matches is <= limit. In that case, the number of suggestions displayed is max(limit - results, results). For instance, in my case when the query returns 10 matches, 0 results are displayed. When the query returns 8 matches, 2 results are displayed. When the query returns 3 matches, 3 results are displayed, and so on.
The text was updated successfully, but these errors were encountered: