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

Modal doesn't always close on outside click if browser is heavily loaded #5080

Closed
@jessefoster

Description

@jessefoster

It seems like #2280 accidentally changed the api of one of your calls. You registered click events outside the modal via ng-click before. However #2280 bugfix switched to using element.on('click') instead. This is not the same as the event handler may run outside of a digest cycle if the browser is heavily loaded.

Howevever looking at ng-click's code you can see it always wraps the click handlers with $apply.
https://github.com/angular/angular.js/blob/master/src/ng/directive/ngEventDirs.js#L61-L71

 element.on(eventName, function(event) {
    var callback = function() {
        fn(scope, {$event:event});
    };
    if (forceAsyncEvents[eventName] && $rootScope.$$phase) {
        scope.$evalAsync(callback);
    } else {
        scope.$apply(callback);
    }
});

I can't reproduce this in a plunker at it happens too randomly. However I haven't seen the issue reappear since wrapping the scope.close click handler with $apply.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions