From 3de91bdc408cea1437a9badbce1b259206f9ce75 Mon Sep 17 00:00:00 2001 From: Tuomo Jokimies Date: Tue, 16 Feb 2016 14:49:21 +0200 Subject: [PATCH] fix(modal): fix race condition with openedClass --- src/modal/modal.js | 4 +++- src/modal/test/modal.spec.js | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/modal/modal.js b/src/modal/modal.js index a910ae563a..3025e0d136 100644 --- a/src/modal/modal.js +++ b/src/modal/modal.js @@ -479,7 +479,9 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap']) $animate.enter($compile(angularDomEl)(modal.scope), appendToElement) .then(function() { - $animate.addClass(appendToElement, modalBodyClass); + if (!modal.scope.$$uibDestructionScheduled) { + $animate.addClass(appendToElement, modalBodyClass); + } }); openedWindows.top().value.modalDomEl = angularDomEl; diff --git a/src/modal/test/modal.spec.js b/src/modal/test/modal.spec.js index dccb65009a..fae3a34556 100644 --- a/src/modal/test/modal.spec.js +++ b/src/modal/test/modal.spec.js @@ -1219,6 +1219,16 @@ describe('$uibModal', function() { expect(body).not.toHaveClass('bar'); expect(body).not.toHaveClass('modal-open'); }); + + it('should not add the modal-open class if modal is closed before animation', function() { + var modal = open({ + template: '
dummy modal
' + }, true); + + close(modal); + + expect(body).not.toHaveClass('modal-open'); + }); }); });