Skip to content

Commit

Permalink
Fix flickering of remote-only menu
Browse files Browse the repository at this point in the history
  • Loading branch information
joekur committed May 8, 2015
1 parent 588440f commit 79b4f08
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/typeahead/dataset.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,9 @@ var Dataset = (function() {
suggestions = (suggestions || []).slice(0, that.limit);
rendered = suggestions.length;

that._overwrite(query, suggestions);
if (suggestions.length) {
that._overwrite(query, suggestions);
}

if (rendered < that.limit && that.async) {
that.trigger('asyncRequested', query);
Expand All @@ -269,9 +271,14 @@ var Dataset = (function() {
// do not render the suggestions as they've become outdated
if (!canceled && rendered < that.limit) {
that.cancel = $.noop;
rendered += suggestions.length;
that._append(query, suggestions.slice(0, that.limit - rendered));

if (rendered === 0) {
that._overwrite(query, suggestions.slice(0, that.limit - rendered));
} else {
that._append(query, suggestions.slice(0, that.limit - rendered));
}

rendered += suggestions.length;
that.async && that.trigger('asyncReceived', query);
}
}
Expand Down

0 comments on commit 79b4f08

Please sign in to comment.