diff --git a/src/dropdown/docs/readme.md b/src/dropdown/docs/readme.md index 3593aa999c..09b646d072 100644 --- a/src/dropdown/docs/readme.md +++ b/src/dropdown/docs/readme.md @@ -14,7 +14,7 @@ Each of these parts need to be used as attribute directives. _(Default: `always`)_ - Controls the behavior of the menu when clicked. * `always` - Automatically closes the dropdown when any of its elements is clicked. - * `disabled` - Disables the auto close. You can control it manually with `is-open`. It still gets closed if the toggle is clicked, `esc` is pressed or another dropdown is open. It also won't be closed on `$locationchangeSuccess`. + * `disabled` - Disables the auto close. You can control it manually with `is-open`. It still gets closed if the toggle is clicked, `esc` is pressed or another dropdown is open. * `outsideClick` - Closes the dropdown automatically only when the user clicks any element outside the dropdown. * `dropdown-append-to` diff --git a/src/dropdown/dropdown.js b/src/dropdown/dropdown.js index f5ae0ec269..f9db3ed7ef 100644 --- a/src/dropdown/dropdown.js +++ b/src/dropdown/dropdown.js @@ -268,12 +268,6 @@ angular.module('ui.bootstrap.dropdown', ['ui.bootstrap.position']) setIsOpen($scope, isOpen); } }); - - $scope.$on('$locationChangeSuccess', function() { - if (scope.getAutoClose() !== 'disabled') { - scope.isOpen = false; - } - }); }]) .directive('uibDropdown', function() { diff --git a/src/dropdown/test/dropdown.spec.js b/src/dropdown/test/dropdown.spec.js index 9d7977b902..cdef7512c2 100644 --- a/src/dropdown/test/dropdown.spec.js +++ b/src/dropdown/test/dropdown.spec.js @@ -88,14 +88,6 @@ describe('uib-dropdown', function() { expect(element).toHaveClass(dropdownConfig.openClass); }); - it('should close on $location change', function() { - clickDropdownToggle(); - expect(element).toHaveClass(dropdownConfig.openClass); - $rootScope.$broadcast('$locationChangeSuccess'); - $rootScope.$apply(); - expect(element).not.toHaveClass(dropdownConfig.openClass); - }); - it('should only allow one dropdown to be open at once', function() { var elm1 = dropdown(); var elm2 = dropdown(); @@ -279,32 +271,6 @@ describe('uib-dropdown', 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('
  • ' + - '
  • ')($rootScope); - } - - beforeEach(function() { - element = dropdown(); - }); - - it('should close without errors on $location change', function() { - $document.find('body').append(element); - clickDropdownToggle(); - expect(element).toHaveClass(dropdownConfig.openClass); - var optionEl = element.find('ul > li').eq(0).find('a').eq(0); - optionEl.click(); - expect(element).not.toHaveClass(dropdownConfig.openClass); - }); - }); - describe('using is-open', function() { describe('with uib-dropdown-toggle', function() { beforeEach(function() { @@ -521,16 +487,6 @@ describe('uib-dropdown', function() { expect(elm1).not.toHaveClass(dropdownConfig.openClass); expect(elm2).toHaveClass(dropdownConfig.openClass); }); - - it('should not close on $locationChangeSuccess if auto-close="disabled"', function() { - var elm1 = dropdown('disabled'); - expect(elm1).not.toHaveClass(dropdownConfig.openClass); - clickDropdownToggle(elm1); - expect(elm1).toHaveClass(dropdownConfig.openClass); - $rootScope.$broadcast('$locationChangeSuccess'); - $rootScope.$digest(); - expect(elm1).toHaveClass(dropdownConfig.openClass); - }); }); describe('outsideClick', function() {