Skip to content

Commit 41b73ab

Browse files
committed
fix(ionNavBar): adjust has-header if ionNavBar is hidden
Fixes #927.
1 parent 75290a3 commit 41b73ab

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

js/ext/angular/src/directive/ionicNavBar.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ function($scope, $element, $attrs, $ionicViewService, $animate, $compile, $ionic
144144

145145
this.showBar = function(show) {
146146
$scope.isInvisible = !show;
147+
$scope.$parent.$hasHeader = !!show;
147148
};
148149

149150
this.setTitle = function(title) {
@@ -290,7 +291,6 @@ function($ionicViewService, $rootScope, $animate, $compile) {
290291
$scope.shouldAnimate = true;
291292
$scope.isReverse = false;
292293
$scope.isInvisible = true;
293-
$scope.$parent.$hasHeader = true;
294294

295295
$scope.$on('$destroy', function() {
296296
$scope.$parent.$hasHeader = false;

js/ext/angular/test/directive/ionicNavBar.unit.js

+13-3
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ describe('ionNavBar', function() {
7474
expect($scope.backButtonShown).toBe(false);
7575
});
7676

77-
it('should showBar', function() {
77+
it('showBar should set isInvisible', function() {
7878
var ctrl = setup();
7979
expect($scope.isInvisible).toBeUndefined();
8080
ctrl.showBar(true);
@@ -83,6 +83,15 @@ describe('ionNavBar', function() {
8383
expect($scope.isInvisible).toBe(true);
8484
});
8585

86+
it('showBar should set $parent.$hasHeader', function() {
87+
var ctrl = setup();
88+
expect($scope.$parent.$hasHeader).toBeUndefined();
89+
ctrl.showBar(true);
90+
expect($scope.$parent.$hasHeader).toBe(true);
91+
ctrl.showBar(false);
92+
expect($scope.$parent.$hasHeader).toBe(false);
93+
});
94+
8695
it('should setTitle', function() {
8796
var ctrl = setup();
8897
expect($scope.title).toBeFalsy();
@@ -230,10 +239,10 @@ describe('ionNavBar', function() {
230239
expect(el.children().eq(0).html()).toBe('<b>super</b> content 4');
231240
});
232241

233-
it('should $parent.$hasHeader and unset on $destroy', function() {
242+
it('should set $parent.$hasHeader to false on $scope.$destroy', function() {
234243
var el = setup();
235244
var parentScope = el.scope().$parent;
236-
expect(parentScope.$hasHeader).toBe(true);
245+
parentScope.$hasHeader = true;
237246
el.scope().$destroy();
238247
expect(parentScope.$hasHeader).toBe(false);
239248
});
@@ -255,6 +264,7 @@ describe('ionNavBar', function() {
255264

256265
it('should have invisible class (default true)', function() {
257266
var el = setup();
267+
el.scope().$apply();
258268
expect(el.hasClass('invisible')).toBe(true);
259269
el.scope().$apply('isInvisible = false');
260270
expect(el.hasClass('invisible')).toBe(false);

0 commit comments

Comments
 (0)