Skip to content

Commit

Permalink
amend($ionicModal): if hardwareBackButtonClose false, back button is …
Browse files Browse the repository at this point in the history
…noop

Addresses #1397
  • Loading branch information
ajoslin committed Jun 5, 2014
1 parent 53af788 commit 9942045
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
10 changes: 4 additions & 6 deletions js/angular/service/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,10 @@ function($rootScope, $document, $compile, $timeout, $ionicPlatform, $ionicTempla
.removeClass('ng-leave ng-leave-active');

self._isShown = true;
self._deregisterBackButton = self.hardwareBackButtonClose ?
$ionicPlatform.registerBackButtonAction(
angular.bind(self, self.hide),
PLATFORM_BACK_BUTTON_PRIORITY_MODAL
) :
angular.noop;
self._deregisterBackButton = $ionicPlatform.registerBackButtonAction(
self.hardwareBackButtonClose ? angular.bind(self, self.hide) : angular.noop,
PLATFORM_BACK_BUTTON_PRIORITY_MODAL
);

self._isOpenPromise = $q.defer();

Expand Down
Empty file.
8 changes: 6 additions & 2 deletions test/unit/angular/service/modal.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,14 @@ describe('Ionic Modal', function() {
var instance = modal.fromTemplate(template, {
hardwareBackButtonClose: false
});
spyOn($ionicPlatform, 'registerBackButtonAction');
spyOn($ionicPlatform, 'registerBackButtonAction').andCallThrough();
instance.show();
timeout.flush();
expect($ionicPlatform.registerBackButtonAction).not.toHaveBeenCalled();
expect($ionicPlatform.registerBackButtonAction).toHaveBeenCalledWith(jasmine.any(Function), PLATFORM_BACK_BUTTON_PRIORITY_MODAL);

ionicPlatform.hardwareBackButtonClick();

expect(instance.isShown()).toBe(true);
}));

it('should call _deregisterBackButton on hide', function() {
Expand Down

0 comments on commit 9942045

Please sign in to comment.