diff --git a/src/dropdown/dropdown.js b/src/dropdown/dropdown.js index 42b36bef42..e01c830847 100644 --- a/src/dropdown/dropdown.js +++ b/src/dropdown/dropdown.js @@ -29,6 +29,10 @@ angular.module('ui.bootstrap.dropdown', []) }; var closeDropdown = function( evt ) { + // This method may still be called during the same mouse event that + // unbound this event handler. So check openScope before proceeding. + if (!openScope) { return; } + var toggleElement = openScope.getToggleElement(); if ( evt && toggleElement && toggleElement[0].contains(evt.target) ) { return; diff --git a/src/dropdown/test/dropdown.spec.js b/src/dropdown/test/dropdown.spec.js index 2bc379708a..262549aeea 100644 --- a/src/dropdown/test/dropdown.spec.js +++ b/src/dropdown/test/dropdown.spec.js @@ -168,6 +168,33 @@ describe('dropdownToggle', function() { }); }); + describe('integration with $location URL rewriting', function() { + function dropdown() { + + // Simulate URL rewriting behavior + $document.on('click', 'a[href="#something"]', function () { + $rootScope.$broadcast('$locationChangeSuccess'); + $rootScope.$apply(); + }); + + return $compile('