From dd3948015e6895f591ae80a6c57576bc2c260cc9 Mon Sep 17 00:00:00 2001 From: Maarten Winkels Date: Wed, 17 Dec 2014 17:37:59 +0100 Subject: [PATCH] Only resetMatches when showing matches. Make the dismissClickHandler less aggressive by only resetting matches when matches are being shown. Use $apply insetad of $digest. --- src/typeahead/typeahead.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/typeahead/typeahead.js b/src/typeahead/typeahead.js index 8b080d615f..18db52ace1 100644 --- a/src/typeahead/typeahead.js +++ b/src/typeahead/typeahead.js @@ -308,9 +308,8 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap // Keep reference to click handler to unbind it. var dismissClickHandler = function (evt) { - if (element[0] !== evt.target) { - resetMatches(); - scope.$digest(); + if (element[0] !== evt.target && scope.matches.length !== 0) { + scope.$apply(resetMatches); } };