From dde804b6b648fd3752f24bb649747144627c499f Mon Sep 17 00:00:00 2001 From: Pawel Kozlowski Date: Thu, 19 Sep 2013 20:13:37 +0200 Subject: [PATCH] fix(typeahead): remove popup flickering Closes #1011 --- src/typeahead/test/typeahead.spec.js | 3 +++ src/typeahead/typeahead.js | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/typeahead/test/typeahead.spec.js b/src/typeahead/test/typeahead.spec.js index bd72720caa..0675f257a1 100644 --- a/src/typeahead/test/typeahead.spec.js +++ b/src/typeahead/test/typeahead.spec.js @@ -127,6 +127,9 @@ describe('typeahead tests', function () { var element = prepareInputEl("
"); changeInputValueTo(element, 'ba'); expect(element).toBeOpenWithActive(2, 0); + + changeInputValueTo(element, ''); + expect(element).toBeClosed(); }); it('should not open typeahead if input value smaller than a defined threshold', function () { diff --git a/src/typeahead/typeahead.js b/src/typeahead/typeahead.js index f4fd17725f..aba06a3d73 100644 --- a/src/typeahead/typeahead.js +++ b/src/typeahead/typeahead.js @@ -145,7 +145,6 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap //$parsers kick-in on all the changes coming from the view as well as manually triggered by $setViewValue modelCtrl.$parsers.unshift(function (inputValue) { - resetMatches(); if (inputValue && inputValue.length >= minSearch) { if (waitTime > 0) { if (timeoutPromise) { @@ -157,6 +156,8 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap } else { getMatchesAsync(inputValue); } + } else { + resetMatches(); } if (isEditable) {