-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Conversation
Used timeout to avoid $rootScope:inprog error
https://github.com/angular-ui/bootstrap/pull/1744/files |
Not really! :) it's the way angularjs cycles are designed. |
@@ -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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using setTimeout, use $timeout with false for invokeApply.
This fix looks good to me, except for the change I highlighted to use $timeout instead. |
@@ -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 | |||
$timeout(function() { element[0].focus(); }, 1, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does $timeout(function() { element[0].focus(); }, 0, false);
work? Was there a reason for picking the values 1 and true
(invokeApply = true)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked and it does work with 0 and false (see http://plnkr.co/FimbQhGviK5dDVarLaRy). I'll give you another commit.
Thank you, @shayanelhami ! I've added a test and merged it. |
Your solution is great @chrisirhc, just tested and it is working. Good to know it will be merged. |
Used timeout to avoid $rootScope:inprog error