From 5658a4df0c2221f867ec3e0f6484f58094d516b4 Mon Sep 17 00:00:00 2001 From: Perry Govier Date: Fri, 26 Sep 2014 16:43:27 -0500 Subject: [PATCH] fix(popup): prevent back to back popups from dismissing background. Fixes #2071 --- js/angular/service/popup.js | 4 +++- test/unit/angular/service/popup.unit.js | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/js/angular/service/popup.js b/js/angular/service/popup.js index ddd56867b50..20f03f9f021 100644 --- a/js/angular/service/popup.js +++ b/js/angular/service/popup.js @@ -403,7 +403,9 @@ function($ionicTemplateLoader, $ionicBackdrop, $q, $timeout, $rootScope, $ionicB // click which would trigging whatever was underneath this $ionicBody.removeClass('popup-open'); }, 400); - $ionicBackdrop.release(); + $timeout(function(){ + if(popupStack.length === 0)$ionicBackdrop.release(); + }, config.stackPushDelay || 0); ($ionicPopup._backButtonActionDone || angular.noop)(); } return result; diff --git a/test/unit/angular/service/popup.unit.js b/test/unit/angular/service/popup.unit.js index ebb7e36c670..d533752ff5f 100644 --- a/test/unit/angular/service/popup.unit.js +++ b/test/unit/angular/service/popup.unit.js @@ -265,9 +265,9 @@ describe('$ionicPopup service', function() { $ionicPopup.show(); fakePopup.responseDeferred.resolve(); $timeout.flush(); - expect($ionicBackdrop.release).toHaveBeenCalled(); expect(backDoneSpy).toHaveBeenCalled(); $timeout.flush(); + expect($ionicBackdrop.release).toHaveBeenCalled(); expect(document.body.classList.contains('popup-open')).toBe(false); })); it('template should only overwrite prompt input if it includes html', inject(function($timeout) {