-
Notifications
You must be signed in to change notification settings - Fork 6.7k
fix(dropdown): Fix $digest:inprog on dropdown dismissal #3274
fix(dropdown): Fix $digest:inprog on dropdown dismissal #3274
Conversation
I'm a bit confused why we would get a $digest in progress error in that method. That method is only called on events on document, where an $apply is necessary. Can you explain this further? |
This is because the click event was triggered manually by a |
Hm, can't say I like the solution terribly much, but I think it is correct. Can you make the modification to check if !$rootScope.$$phase before executing $rootScope.$digest? |
For sure. I'll try to get something up tomorrow. |
Hmmm... while checking I can post the change for checking |
Is there any particular reason why the dropdown would not be dismissed by this check? That seems strange to me. |
Can you explain why checking for |
If we do the check like such
then openScope.isOpen won't be set to false and the dropdown will stay open ( We could instead do
but that doesn't feel like a cleaner solution compared to just using |
I was actually referring to doing $apply only when it's needed. You can do:
Note that you need to check Edit: Looking at the source code of Angular, looks like only the |
Doh! 😊 Yup, that makes sense. I'll rollback and condense it all into one patch. Forgot that you can call |
Could occur when click event handled during digest cycle (through another directive, etc.) Signed-off-by: Max Fierke <[email protected]>
1cee95a
to
fc86a87
Compare
@maxfierke , mind adding a test for this? You can do the $document.click in your test 😄 |
Signed-off-by: Max Fierke <[email protected]>
Done 😄 |
Thanks, merged it in! |
Make $apply first check if $rootScope is in $digest cycle before executing Closes angular-ui#3274
Make $apply first check if $rootScope is in $digest cycle before executing Closes angular-ui#3274
Make $apply first check if $rootScope is in $digest cycle before executing Closes angular-ui#3274
Make $apply first check if $rootScope is in $digest cycle before executing Closes angular-ui#3274
Make $apply first check if $rootScope is in $digest cycle before executing Closes angular-ui#3274
Make $apply first check if $rootScope is in $digest cycle before executing Closes angular-ui#3274
Make $apply first check if $rootScope is in $digest cycle before executing Closes angular-ui#3274
Make $apply first check if $rootScope is in $digest cycle before executing Closes angular-ui#3274
Make $apply first check if $rootScope is in $digest cycle before executing Closes angular-ui#3274
Make $apply first check if $rootScope is in $digest cycle before executing Closes angular-ui#3274
Make $apply first check if $rootScope is in $digest cycle before executing Closes angular-ui#3274
Make $apply first check if $rootScope is in $digest cycle before executing Closes angular-ui#3274
Make $apply first check if $rootScope is in $digest cycle before executing Closes angular-ui#3274
Make $apply first check if $rootScope is in $digest cycle before executing Closes angular-ui#3274
I was working on a project leveraging Angular-UI with a directive that called
$document.click()
to dismiss dropdowns, and ran some callbacks and such, and I was running into a$digest:inprog
exception incloseDropdown
.The prevailing opinion on
$scope.$apply
seems to be that it shouldn't be called directly, and that$timeout
should be used instead.Tested with Angular-UI 0.12 on Angular 1.2.27.
Signed-off-by: Max Fierke [email protected]