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

fix(dropdown): Fix $digest:inprog on dropdown dismissal #3274

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/dropdown/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ angular.module('ui.bootstrap.dropdown', [])
openClass: 'open'
})

.service('dropdownService', ['$document', function($document) {
.service('dropdownService', ['$document', '$rootScope', function($document, $rootScope) {
var openScope = null;

this.open = function( dropdownScope ) {
Expand Down Expand Up @@ -38,9 +38,11 @@ angular.module('ui.bootstrap.dropdown', [])
return;
}

openScope.$apply(function() {
openScope.isOpen = false;
});
openScope.isOpen = false;

if (!$rootScope.$$phase) {
openScope.$apply();
}
};

var escapeKeyBind = function( evt ) {
Expand Down
12 changes: 12 additions & 0 deletions src/dropdown/test/dropdown.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,18 @@ describe('dropdownToggle', function() {
clickDropdownToggle();
expect(toggleEl.attr('aria-expanded')).toBe('false');
});

// pr/issue 3274
it('should not raise $digest:inprog if dismissed during a digest cycle', function () {
clickDropdownToggle();
expect(element.hasClass('open')).toBe(true);

$rootScope.$apply(function () {
$document.click();
});

expect(element.hasClass('open')).toBe(false);
});
});

describe('integration with $location URL rewriting', function() {
Expand Down