From 22a00cd08e38b16bb47bd9191a32c4f90eeb7f41 Mon Sep 17 00:00:00 2001 From: Pawel Kozlowski Date: Tue, 19 Mar 2013 20:31:20 +0100 Subject: [PATCH] fix(typeahead): stop keydown event propagation when ESC pressed to discard matches Closes #243 --- src/typeahead/typeahead.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/typeahead/typeahead.js b/src/typeahead/typeahead.js index 29af035946..6317c6bb2e 100644 --- a/src/typeahead/typeahead.js +++ b/src/typeahead/typeahead.js @@ -126,7 +126,7 @@ angular.module('ui.bootstrap.typeahead', []) modelCtrl.$render(); }; - //bind keyboard events: arrows up(38) / down(40), enter(13) and tab(9), esc(9) + //bind keyboard events: arrows up(38) / down(40), enter(13) and tab(9), esc(27) element.bind('keydown', function (evt) { //typeahead is open and an "interesting" key was pressed @@ -150,6 +150,7 @@ angular.module('ui.bootstrap.typeahead', []) }); } else if (evt.which === 27) { + evt.stopPropagation(); scope.matches = []; scope.$digest(); }