From 409b7aa3b36c7c5a2acd8f14555d2ae4666eb5b5 Mon Sep 17 00:00:00 2001 From: Anthony Cleaver Date: Mon, 27 Jun 2016 08:37:50 +0100 Subject: [PATCH] fix(modal): remove window class after animation - Wait until animations are complete before removing window class BREAKING CHANGE: This introduces a minor behavior change in when the class is removed Closes #6056 Fixes #6051 --- src/modal/modal.js | 7 ++++--- src/modal/test/modal.spec.js | 10 ++++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/modal/modal.js b/src/modal/modal.js index f5729d59b3..88aee826d9 100644 --- a/src/modal/modal.js +++ b/src/modal/modal.js @@ -375,6 +375,10 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap', 'ui.bootstrap.p afterAnimating.done = true; $animate.leave(domEl).then(function() { + if (done) { + done(); + } + domEl.remove(); if (closedDeferred) { closedDeferred.resolve(); @@ -382,9 +386,6 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap', 'ui.bootstrap.p }); scope.$destroy(); - if (done) { - done(); - } } } diff --git a/src/modal/test/modal.spec.js b/src/modal/test/modal.spec.js index 4253b487ae..84fd7cf381 100644 --- a/src/modal/test/modal.spec.js +++ b/src/modal/test/modal.spec.js @@ -1390,7 +1390,7 @@ describe('$uibModal', function() { expect(body).not.toHaveClass('modal-open'); }); - it('should remove the custom class on closing of modal', function() { + it('should remove the custom class on closing of modal after animations have completed', function() { var modal = open({ template: '
dummy modal
', openedClass: 'foo' @@ -1398,7 +1398,13 @@ describe('$uibModal', function() { expect(body).toHaveClass('foo'); - close(modal); + close(modal, null, true); + expect(body).toHaveClass('foo'); + + $animate.flush(); + $rootScope.$digest(); + $animate.flush(); + $rootScope.$digest(); expect(body).not.toHaveClass('foo'); });