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

Commit

Permalink
fix(collapse): Prevent consecutive transitions & tidy up code
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
chrisirhc authored and pkozlowski-opensource committed Dec 28, 2013
1 parent 517dff6 commit b0032d6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/collapse/collapse.js
Expand Up @@ -75,7 +75,6 @@ angular.module('ui.bootstrap.collapse', ['ui.bootstrap.transition'])
expand();
}
});

}
};
}]);
17 changes: 17 additions & 0 deletions src/collapse/test/collapse.spec.js
Expand Up @@ -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('<div collapse="isCollapsed"><p>Initial content</p><div ng-show="exp">Additional content</div></div>');
Expand Down

0 comments on commit b0032d6

Please sign in to comment.