From 04a21e33b03323946662fb83abf2dbbf058cc5d0 Mon Sep 17 00:00:00 2001 From: Charles Date: Thu, 6 Jun 2013 14:59:58 -0300 Subject: [PATCH] fix(typeahead): return focus to the input after selecting a suggestion Currently focus is lost if you mouse click on the suggestions model instead of using the keyboard. This keeps the focus. --- src/typeahead/typeahead.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/typeahead/typeahead.js b/src/typeahead/typeahead.js index 6cb4c7565c..d19d85cd65 100644 --- a/src/typeahead/typeahead.js +++ b/src/typeahead/typeahead.js @@ -152,12 +152,13 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position']) model = parserResult.modelMapper(scope, locals); modelCtrl.$setViewValue(model); modelCtrl.$render(); - onSelectCallback(scope, { $item: item, $model: model, $label: parserResult.viewMapper(scope, locals) }); + + element[0].focus(); }; //bind keyboard events: arrows up(38) / down(40), enter(13) and tab(9), esc(27) @@ -244,4 +245,4 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position']) return function(matchItem, query) { return query ? matchItem.replace(new RegExp(escapeRegexp(query), 'gi'), '$&') : query; }; - }); \ No newline at end of file + });