From d95d35e814099d74355ed431e85a957d39ec4745 Mon Sep 17 00:00:00 2001 From: Michael Benford Date: Sat, 12 Apr 2014 01:44:01 -0300 Subject: [PATCH] fix(autocomplete): Fix autocomplete navigation when maxResultsToShow 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 --- src/auto-complete.js | 4 +++- templates/auto-complete.html | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/auto-complete.js b/src/auto-complete.js index 8629ddc9..09b33bfb 100644 --- a/src/auto-complete.js +++ b/src/auto-complete.js @@ -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(); } diff --git a/templates/auto-complete.html b/templates/auto-complete.html index 1202f760..e5ac5274 100644 --- a/templates/auto-complete.html +++ b/templates/auto-complete.html @@ -1,7 +1,7 @@