fix(sideMenu): Prevent is-enabled="false" from blocking current view interaction. Fixes #1973

This commit is contained in:
Perry Govier
2014-09-22 14:26:58 -05:00
parent aa7e9dd7a9
commit cedee5749a
2 changed files with 22 additions and 2 deletions

View File

@@ -50,7 +50,7 @@ function($scope, $attrs, $ionicSideMenuDelegate, $ionicPlatform, $ionicBody) {
* Toggle the left menu to open 100%
*/
self.toggleLeft = function(shouldOpen) {
if(isAsideExposed) return;
if(isAsideExposed || !self.left.isEnabled) return;
var openAmount = self.getOpenAmount();
if (arguments.length === 0) {
shouldOpen = openAmount <= 0;
@@ -67,7 +67,7 @@ function($scope, $attrs, $ionicSideMenuDelegate, $ionicPlatform, $ionicBody) {
* Toggle the right menu to open 100%
*/
self.toggleRight = function(shouldOpen) {
if(isAsideExposed) return;
if(isAsideExposed || !self.right.isEnabled) return;
var openAmount = self.getOpenAmount();
if (arguments.length === 0) {
shouldOpen = openAmount >= 0;

View File

@@ -120,6 +120,26 @@ describe('$ionicSideMenus controller', function() {
expect(ctrl.getOpenPercentage()).toEqual(0);
});
it('should not toggle left when disabled', function() {
expect(ctrl.getOpenPercentage()).toEqual(0);
ctrl.left.isEnabled = false;
ctrl.toggleLeft();
expect(ctrl.getOpenPercentage()).toEqual(0);
ctrl.left.isEnabled = true;
ctrl.toggleLeft();
expect(ctrl.getOpenPercentage()).toNotEqual(0);
});
it('should not toggle right when disabled', function() {
expect(ctrl.getOpenPercentage()).toEqual(0);
ctrl.right.isEnabled = false;
ctrl.toggleRight();
expect(ctrl.getOpenPercentage()).toEqual(0);
ctrl.right.isEnabled = true;
ctrl.toggleRight();
expect(ctrl.getOpenPercentage()).toNotEqual(0);
});
it('should close left menu on expose aside', function() {
ctrl.toggleLeft();
expect(ctrl.getOpenPercentage()).toEqual(100);