From acf423a4c109e10855ef2840892a843fb7399d47 Mon Sep 17 00:00:00 2001 From: Shayan Elhami Date: Wed, 12 Feb 2014 22:36:44 +0000 Subject: [PATCH 1/3] Update typeahead to fix #1773 Used timeout to avoid $rootScope:inprog error --- 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 8547c6f587..19df80a1d3 100644 --- a/src/typeahead/typeahead.js +++ b/src/typeahead/typeahead.js @@ -222,7 +222,8 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap resetMatches(); //return focus to the input element if a mach was selected via a mouse click event - element[0].focus(); + // use timeout to avoid $rootScope:inprog error + setTimeout(function() { element[0].focus(); }, 1); }; //bind keyboard events: arrows up(38) / down(40), enter(13) and tab(9), esc(27) @@ -346,4 +347,4 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap return function(matchItem, query) { return query ? ('' + matchItem).replace(new RegExp(escapeRegexp(query), 'gi'), '$&') : matchItem; }; - }); \ No newline at end of file + }); From caeac338af1fcb4b1b639eaccddbc4148c9d491e Mon Sep 17 00:00:00 2001 From: Shayan Elhami Date: Tue, 18 Feb 2014 16:42:25 +0000 Subject: [PATCH 2/3] Fix #1773 by calling focus in a $timeout --- src/typeahead/typeahead.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/typeahead/typeahead.js b/src/typeahead/typeahead.js index 19df80a1d3..db73a064df 100644 --- a/src/typeahead/typeahead.js +++ b/src/typeahead/typeahead.js @@ -223,7 +223,7 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap //return focus to the input element if a mach was selected via a mouse click event // use timeout to avoid $rootScope:inprog error - setTimeout(function() { element[0].focus(); }, 1); + $timeout(function() { element[0].focus(); }, 1, true); }; //bind keyboard events: arrows up(38) / down(40), enter(13) and tab(9), esc(27) From 99febb1eb0af59488afe05b7df4b7a91fcc61758 Mon Sep 17 00:00:00 2001 From: Shayan Elhami Date: Mon, 24 Feb 2014 21:37:14 +0000 Subject: [PATCH 3/3] typeahead: fix #1773 with $timeout --- src/typeahead/typeahead.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/typeahead/typeahead.js b/src/typeahead/typeahead.js index db73a064df..0c6699158a 100644 --- a/src/typeahead/typeahead.js +++ b/src/typeahead/typeahead.js @@ -223,7 +223,7 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap //return focus to the input element if a mach was selected via a mouse click event // use timeout to avoid $rootScope:inprog error - $timeout(function() { element[0].focus(); }, 1, true); + $timeout(function() { element[0].focus(); }, 0, false); }; //bind keyboard events: arrows up(38) / down(40), enter(13) and tab(9), esc(27)