From ae87c66b12821b122eeb8acb778138b55776b873 Mon Sep 17 00:00:00 2001 From: Perry Govier Date: Tue, 5 Aug 2014 11:16:46 -0500 Subject: [PATCH] fix(popup): backdrop release fires with every close --- js/angular/service/popup.js | 4 ++-- test/unit/angular/service/popup.unit.js | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/js/angular/service/popup.js b/js/angular/service/popup.js index 759ab53f44e..b6411db45a2 100644 --- a/js/angular/service/popup.js +++ b/js/angular/service/popup.js @@ -403,10 +403,10 @@ function($ionicTemplateLoader, $ionicBackdrop, $q, $timeout, $rootScope, $docume } else { //Remove popup-open & backdrop if this is last popup document.body.classList.remove('popup-open'); - $ionicBackdrop.release(); ($ionicPopup._backButtonActionDone || angular.noop)(); } - + // always release the backdrop since it has an internal backdrop counter + $ionicBackdrop.release(); return result; }); }); diff --git a/test/unit/angular/service/popup.unit.js b/test/unit/angular/service/popup.unit.js index 9d2911d5c9e..e1a771cd8b3 100644 --- a/test/unit/angular/service/popup.unit.js +++ b/test/unit/angular/service/popup.unit.js @@ -251,7 +251,7 @@ describe('$ionicPopup service', function() { expect(previousPopup.show).toHaveBeenCalled(); })); - it('should release backdrop and remove popup-open and deregister back if no previous', inject(function($q, $timeout, $ionicBackdrop, $ionicPlatform) { + it('should always release backdrop and remove popup-open and deregister back if no previous', inject(function($q, $timeout, $ionicBackdrop, $ionicPlatform) { var fakePopup = { show: jasmine.createSpy('show'), remove: jasmine.createSpy('remove'), @@ -268,5 +268,13 @@ describe('$ionicPopup service', function() { expect(backDoneSpy).toHaveBeenCalled(); expect(document.body.classList.contains('popup-open')).toBe(false); })); + it('backdrop release should be called even if there are multiple popups', inject(function($q, $timeout, $ionicBackdrop) { + popup = $ionicPopup.show(); + popup2 = $ionicPopup.show(); + spyOn($ionicBackdrop, 'release'); + popup.close(); + $timeout.flush(); + expect($ionicBackdrop.release).toHaveBeenCalled(); + })); }); });