From 4f48e9ae47cc646cdb4ae0a8324336444e2fc8eb Mon Sep 17 00:00:00 2001 From: Wesley Cho Date: Sat, 1 Aug 2015 08:20:57 -0700 Subject: [PATCH] fix(typeahead): reset matches if enter is hit - If no match is selected and enter is hit, reset matches --- src/typeahead/typeahead.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/typeahead/typeahead.js b/src/typeahead/typeahead.js index 5d744971d7..f719c79a06 100644 --- a/src/typeahead/typeahead.js +++ b/src/typeahead/typeahead.js @@ -354,13 +354,8 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap return; } - // if there's nothing selected (i.e. focusFirst) and enter is hit, don't do anything - if (scope.activeIdx === -1 && evt.which === 13) { - return; - } - - // if there's nothing selected (i.e. focusFirst) and tab is hit, clear the results - if (scope.activeIdx === -1 && evt.which === 9) { + // if there's nothing selected (i.e. focusFirst) and enter or tab is hit, clear the results + if (scope.activeIdx === -1 && (evt.which === 9 || evt.which === 13)) { resetMatches(); scope.$digest(); return;