Skip to content
This repository has been archived by the owner on Nov 22, 2021. It is now read-only.

Commit

Permalink
fix(autocomplete): Fixed suggestion box visibility
Browse files Browse the repository at this point in the history
Fixed a bug in the show method of the SuggestionList class that caused
the suggestion box to be displayed even when there was no items to show.
  • Loading branch information
mbenford committed Dec 2, 2013
1 parent 0c75803 commit c2b43c6
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build/ng-tags-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ angular.module('tags-input').directive('autoComplete', ["$document","$timeout","
self.query = query;
loadFn({ $query: query }).then(function(items) {
self.items = getDifference(items, tags);
if (items.length > 0) {
if (self.items.length > 0) {
self.show();
}
});
Expand Down
Binary file modified build/ng-tags-input.min.zip
Binary file not shown.
Binary file modified build/ng-tags-input.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion src/auto-complete.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ angular.module('tags-input').directive('autoComplete', function($document, $time
self.query = query;
loadFn({ $query: query }).then(function(items) {
self.items = getDifference(items, tags);
if (items.length > 0) {
if (self.items.length > 0) {
self.show();
}
});
Expand Down
9 changes: 9 additions & 0 deletions test/auto-complete.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,15 @@ describe('autocomplete-directive', function() {
expect(isSuggestionsBoxVisible()).toBe(false);
});

it('hides the suggestions list when there is no items left to show', function() {
// Act
tagsInput.getTags.andReturn(['Item1', 'Item2', 'Item3']);
loadSuggestions(['Item1', 'Item2', 'Item3']);

// Assert
expect(isSuggestionsBoxVisible()).toBe(false);
});

it('hides the suggestion box when the input field becomes empty', function() {
// Arrange
changeInputValue('foobar');
Expand Down

0 comments on commit c2b43c6

Please sign in to comment.