mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
amend($ionicModal): if hardwareBackButtonClose false, back button is noop
Addresses #1397
This commit is contained in:
10
js/angular/service/modal.js
vendored
10
js/angular/service/modal.js
vendored
@@ -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();
|
||||
|
||||
|
||||
0
test/unit/angular/directive/gestures.js
vendored
Normal file
0
test/unit/angular/directive/gestures.js
vendored
Normal file
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user