From 84bb9166726321944d03dbf5b4aefc27e1f2a8ab Mon Sep 17 00:00:00 2001 From: Michael Benford Date: Sun, 1 Dec 2013 01:38:57 -0200 Subject: [PATCH] fix(tagsInput): Added event trigger to tryAdd Changed tryAdd method to trigger an input-changed event after clearing the input field so the autocomplete directive can hide the suggestions box properly. Closes #26. --- src/auto-complete.js | 3 --- src/tags-input.js | 1 + test/auto-complete.spec.js | 11 ----------- 3 files changed, 1 insertion(+), 14 deletions(-) diff --git a/src/auto-complete.js b/src/auto-complete.js index d559accc..58679ec5 100644 --- a/src/auto-complete.js +++ b/src/auto-complete.js @@ -136,9 +136,6 @@ angular.module('tags-input').directive('autoComplete', function($document, $time }; tagsInput - .on('tag-added', function() { - suggestionList.reset(); - }) .on('input-changed', function(value) { if (value) { suggestionList.load(value); diff --git a/src/tags-input.js b/src/tags-input.js index 33342810..7a707615 100644 --- a/src/tags-input.js +++ b/src/tags-input.js @@ -115,6 +115,7 @@ angular.module('tags-input').directive('tagsInput', function(configuration) { } $scope.newTag = ''; + events.trigger('input-changed', ''); changed = true; } return changed; diff --git a/test/auto-complete.spec.js b/test/auto-complete.spec.js index 84df66c3..ee6e07a9 100644 --- a/test/auto-complete.spec.js +++ b/test/auto-complete.spec.js @@ -174,17 +174,6 @@ describe('autocomplete-directive', function() { expect(isSuggestionsBoxVisible()).toBe(false); }); - it('hides the suggestion box when a tag is added', function() { - // Arrange - suggestionList.show(); - - // Act - eventHandlers['tag-added'](); - - // Assert - expect(isSuggestionsBoxVisible()).toBe(false); - }); - it('adds the selected suggestion to the input field when the enter key is pressed and the suggestions box is visible', function() { // Arrange loadSuggestions(['Item1', 'Item2']);