sergeyt / meteor-typeahead

Autocomplete package for meteor powered by twitter typeahead.js
https://atmospherejs.com/sergeyt/typeahead
MIT License
146 stars 82 forks source link

Server side search doesn't always return all results #95

Closed jorgepozas closed 9 years ago

jorgepozas commented 9 years ago

First off, thanks for the great wrapper! As I've been using it more and more, I noticed an issue.

When getting back 4 results from server, and passing them into callback, only one ends up displayed in the suggestions. This is with a 5 suggestion limit.

I was looking through code and it seems like an issue in the async function, where suggestions are being sliced erroneously when appended. When running through the below code, rendered is initally equal to 0, suggestions.length =4, and that.limit = 5. The below code basically implies that suggestions should be sliced from 0 to (5-4 = 1) which means that only one suggestion is shown instead of all 4.

Am I missing something?

function async(suggestions) { ... rendered += suggestions.length; that._append(query, suggestions.slice(0, that.limit - rendered)); ... }

limbit commented 9 years ago

I also was struggling with this. You can get around this by increasing the 'data-limit' attribute to a higher value than your serverside-limit + 5 (see https://github.com/sergeyt/meteor-typeahead/issues/74)

Volodymyr-K commented 9 years ago

This bug was copied from the original twitter's typeahead.js library See here https://github.com/twitter/typeahead.js/issues/1354