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

Commit b0032d6

Browse files
chrisirhcpkozlowski-opensource
authored andcommitted
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.
1 parent 517dff6 commit b0032d6

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/collapse/collapse.js

-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ angular.module('ui.bootstrap.collapse', ['ui.bootstrap.transition'])
7575
expand();
7676
}
7777
});
78-
7978
}
8079
};
8180
}]);

src/collapse/test/collapse.spec.js

+17
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,23 @@ describe('collapse directive', function () {
5555
expect(element.height()).not.toBe(0);
5656
});
5757

58+
it('should expand if isCollapsed = true with animation on subsequent uses', function() {
59+
scope.isCollapsed = false;
60+
scope.$digest();
61+
scope.isCollapsed = true;
62+
scope.$digest();
63+
scope.isCollapsed = false;
64+
scope.$digest();
65+
scope.isCollapsed = true;
66+
scope.$digest();
67+
$timeout.flush();
68+
expect(element.height()).toBe(0);
69+
if ($transition.transitionEndEventName) {
70+
element.triggerHandler($transition.transitionEndEventName);
71+
expect(element.height()).toBe(0);
72+
}
73+
});
74+
5875
describe('dynamic content', function() {
5976
beforeEach(function() {
6077
element = angular.element('<div collapse="isCollapsed"><p>Initial content</p><div ng-show="exp">Additional content</div></div>');

0 commit comments

Comments
 (0)