From 64f51829d44bea373b38a5db61552e03a2cc02de Mon Sep 17 00:00:00 2001 From: Sneha Jain Date: Tue, 12 May 2015 11:57:29 +0530 Subject: [PATCH 1/3] Dropdown update animation --- src/dropdown/dropdown.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/dropdown/dropdown.js b/src/dropdown/dropdown.js index 8f03186160..b3325c50fb 100644 --- a/src/dropdown/dropdown.js +++ b/src/dropdown/dropdown.js @@ -128,7 +128,11 @@ angular.module('ui.bootstrap.dropdown', ['ui.bootstrap.position']) }); } - $animate[isOpen ? 'addClass' : 'removeClass'](self.$element, openClass); + $animate[isOpen ? 'addClass' : 'removeClass'](self.$element, openClass).then(function() { +- + if (angular.isDefined(isOpen) && isOpen !== wasOpen) { ++ toggleInvoker($scope, { open: !!isOpen }); ++ } ++ }); if ( isOpen ) { scope.focusToggleElement(); @@ -138,9 +142,6 @@ angular.module('ui.bootstrap.dropdown', ['ui.bootstrap.position']) } setIsOpen($scope, isOpen); - if (angular.isDefined(isOpen) && isOpen !== wasOpen) { - toggleInvoker($scope, { open: !!isOpen }); - } }); $scope.$on('$locationChangeSuccess', function() { From 8ded243c9ad3131b94f8bd6a952369f37a6cf926 Mon Sep 17 00:00:00 2001 From: Sneha Jain Date: Tue, 12 May 2015 12:00:11 +0530 Subject: [PATCH 2/3] Update dropdown.spec.js Added $browser.defer.flush(); for dropdown animation changes --- src/dropdown/test/dropdown.spec.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/dropdown/test/dropdown.spec.js b/src/dropdown/test/dropdown.spec.js index 047ca09720..7b76a4d20f 100644 --- a/src/dropdown/test/dropdown.spec.js +++ b/src/dropdown/test/dropdown.spec.js @@ -1,13 +1,14 @@ describe('dropdownToggle', function() { - var $compile, $rootScope, $document, dropdownConfig, element; + var $compile, $rootScope, $document, dropdownConfig, element, $browser; beforeEach(module('ui.bootstrap.dropdown')); - beforeEach(inject(function(_$compile_, _$rootScope_, _$document_, _dropdownConfig_) { + beforeEach(inject(function(_$compile_, _$rootScope_, _$document_, _dropdownConfig_, _$browser_) { $compile = _$compile_; $rootScope = _$rootScope_; $document = _$document_; dropdownConfig = _dropdownConfig_; + $browser = _$browser_; })); afterEach(function() { @@ -297,9 +298,11 @@ describe('dropdownToggle', function() { it('should call it correctly when toggles', function() { $rootScope.isopen = true; $rootScope.$digest(); + $browser.defer.flush(); expect($rootScope.toggleHandler).toHaveBeenCalledWith(true); clickDropdownToggle(); + $browser.defer.flush(); expect($rootScope.toggleHandler).toHaveBeenCalledWith(false); }); }); @@ -313,16 +316,19 @@ describe('dropdownToggle', function() { }); it('should not have been called initially', function() { + $browser.defer.flush(); expect($rootScope.toggleHandler).not.toHaveBeenCalled(); }); it('should call it correctly when toggles', function() { $rootScope.isopen = false; $rootScope.$digest(); + $browser.defer.flush(); expect($rootScope.toggleHandler).toHaveBeenCalledWith(false); $rootScope.isopen = true; $rootScope.$digest(); + $browser.defer.flush(); expect($rootScope.toggleHandler).toHaveBeenCalledWith(true); }); }); @@ -335,14 +341,17 @@ describe('dropdownToggle', function() { }); it('should not have been called initially', function() { + $browser.defer.flush(); expect($rootScope.toggleHandler).not.toHaveBeenCalled(); }); it('should call it when clicked', function() { clickDropdownToggle(); + $browser.defer.flush(); expect($rootScope.toggleHandler).toHaveBeenCalledWith(true); clickDropdownToggle(); + $browser.defer.flush(); expect($rootScope.toggleHandler).toHaveBeenCalledWith(false); }); }); From 3867a927ffb09a8fcdf2374020ab9de7a64d03a9 Mon Sep 17 00:00:00 2001 From: Sneha Jain Date: Tue, 12 May 2015 12:06:44 +0530 Subject: [PATCH 3/3] Update dropdown.js --- src/dropdown/dropdown.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/dropdown/dropdown.js b/src/dropdown/dropdown.js index b3325c50fb..f5c4b962b1 100644 --- a/src/dropdown/dropdown.js +++ b/src/dropdown/dropdown.js @@ -129,10 +129,10 @@ angular.module('ui.bootstrap.dropdown', ['ui.bootstrap.position']) } $animate[isOpen ? 'addClass' : 'removeClass'](self.$element, openClass).then(function() { -- + if (angular.isDefined(isOpen) && isOpen !== wasOpen) { -+ toggleInvoker($scope, { open: !!isOpen }); -+ } -+ }); + if (angular.isDefined(isOpen) && isOpen !== wasOpen) { + toggleInvoker($scope, { open: !!isOpen }); + } + }); if ( isOpen ) { scope.focusToggleElement();