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

Commit

Permalink
fix(autocomplete): Fix autocomplete navigation when maxResultsToShow …
Browse files Browse the repository at this point in the history
…is set

The maxResultsToShow option is implemented using the limitTo filter, which
limits the number of items to be rendered but doesn't prevent the keyboard
navigation from selecting invisible items.

Closes #109
  • Loading branch information
mbenford committed Apr 12, 2014
1 parent 120d553 commit d95d35e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/auto-complete.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ tagsInput.directive('autoComplete', function($document, $timeout, $sce, tagsInpu
}

items = makeObjectArray(items.data || items, options.tagsInput.displayProperty);
self.items = getDifference(items, tags);
items = getDifference(items, tags);
self.items = items.slice(0, options.maxResultsToShow);

if (self.items.length > 0) {
self.show();
}
Expand Down
2 changes: 1 addition & 1 deletion templates/auto-complete.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="autocomplete" ng-show="suggestionList.visible">
<ul class="suggestion-list">
<li class="suggestion-item"
ng-repeat="item in suggestionList.items | limitTo:options.maxResultsToShow track by track(item)"
ng-repeat="item in suggestionList.items track by track(item)"
ng-class="{selected: item == suggestionList.selected}"
ng-click="addSuggestion()"
ng-mouseenter="suggestionList.select($index)"
Expand Down

0 comments on commit d95d35e

Please sign in to comment.