Skip to content

Commit

Permalink
fix(popup): backdrop release fires with every close
Browse files Browse the repository at this point in the history
  • Loading branch information
perrygovier committed Aug 5, 2014
1 parent 7faeeda commit ae87c66
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions js/angular/service/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
});
Expand Down
10 changes: 9 additions & 1 deletion test/unit/angular/service/popup.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -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();
}));
});
});

0 comments on commit ae87c66

Please sign in to comment.