From b0032d688e105e97faed5c45b74d366417d63193 Mon Sep 17 00:00:00 2001 From: Chris Chua Date: Sun, 24 Nov 2013 16:49:53 -0800 Subject: [PATCH] fix(collapse): Prevent consecutive transitions & tidy up code Previously, there would be a case where the two transitions would run as the cancel would asynchronously invoke the reject handler of the transition which would set the currTransition to undefined even when the currTransition has been replaced with a new transition. --- src/collapse/collapse.js | 1 - src/collapse/test/collapse.spec.js | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/collapse/collapse.js b/src/collapse/collapse.js index bb40a92576..1f5f005f97 100644 --- a/src/collapse/collapse.js +++ b/src/collapse/collapse.js @@ -75,7 +75,6 @@ angular.module('ui.bootstrap.collapse', ['ui.bootstrap.transition']) expand(); } }); - } }; }]); diff --git a/src/collapse/test/collapse.spec.js b/src/collapse/test/collapse.spec.js index d3784ad4c6..f2069b1135 100644 --- a/src/collapse/test/collapse.spec.js +++ b/src/collapse/test/collapse.spec.js @@ -55,6 +55,23 @@ describe('collapse directive', function () { expect(element.height()).not.toBe(0); }); + it('should expand if isCollapsed = true with animation on subsequent uses', function() { + scope.isCollapsed = false; + scope.$digest(); + scope.isCollapsed = true; + scope.$digest(); + scope.isCollapsed = false; + scope.$digest(); + scope.isCollapsed = true; + scope.$digest(); + $timeout.flush(); + expect(element.height()).toBe(0); + if ($transition.transitionEndEventName) { + element.triggerHandler($transition.transitionEndEventName); + expect(element.height()).toBe(0); + } + }); + describe('dynamic content', function() { beforeEach(function() { element = angular.element('

Initial content

Additional content
');