Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Error message when using ng-focus and typeahead at the same time #1773

Closed
shayanelhami opened this issue Feb 10, 2014 · 5 comments
Closed

Error message when using ng-focus and typeahead at the same time #1773

shayanelhami opened this issue Feb 10, 2014 · 5 comments

Comments

@shayanelhami
Copy link
Contributor

If user has a ng-focus directive and tries to select something by mouse from typeahead popup the following error occurs:

[$rootScope:inprog] $apply already in progress

The origin of the error seems to be element[0].focus(); (commit 04a21e3 line 161)

@pkozlowski-opensource
Copy link
Member

@shayanelhami could you please provide a minimal reproduce scenario using http://plnkr.co/? From your description it is not clear where the ng-focus directive is used, what are the versions you are using etc.

@shayanelhami
Copy link
Contributor Author

Here you are: http://plnkr.co/DqTwVPQY54DUj9QI2HH9

Press 'A' select an item by mouse and keep an eye on the errors:
inprog-error

@pkozlowski-opensource
Copy link
Member

Hmm, seems like there is a similar issue opened already on the AngularJS side:
angular/angular.js#5945

I'm probably going to remove this focusing thing as it causes other troubles but it would be cook to get to the bottom of this one.

shayanelhami added a commit to shayanelhami/bootstrap that referenced this issue Feb 12, 2014
Used timeout to avoid $rootScope:inprog error
@shayanelhami
Copy link
Contributor Author

Oh! please don't remove the focusing. It's very helpful.
As a matter of fact I found out that by moving the focus to an asynchronous call it can be fixed. Please see my pull request (#1793).

shayanelhami added a commit to shayanelhami/bootstrap that referenced this issue Feb 18, 2014
shayanelhami added a commit to shayanelhami/bootstrap that referenced this issue Feb 24, 2014
@getuliojr
Copy link

I am having the same error here and need to know what is the fix that will be merged:

  • Removing the line: element[0].focus();
  • or setting it async: $timeout(function() { element[0].focus(); }, 0, false);

Keeping focus looks a better solution to keep tabbing to next field when using keyboard. I will patch my code with second solution for now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants