Skip to content

Commit 5205d09

Browse files
author
Lee Newson
committed
fix(pfVerticalNavigation): Fixed resizing not hiding/showing the navigation correctly
Fixes #728
1 parent 5aac445 commit 5205d09

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/navigation/vertical-navigation.component.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ angular.module('patternfly.navigation').component('pfVerticalNavigation', {
1515
//replace: true,
1616
templateUrl: 'navigation/vertical-navigation.html',
1717
transclude: true,
18-
controller: function ($window, $timeout, $injector, $location, $rootScope) {
18+
controller: function ($window, $timeout, $injector, $location, $rootScope, $scope) {
1919
'use strict';
2020
var routeChangeListener,
2121
ctrl = this,
@@ -552,6 +552,8 @@ angular.module('patternfly.navigation').component('pfVerticalNavigation', {
552552
// Need to bind to resize event
553553
angular.element($window).on('resize', function () {
554554
checkNavState();
555+
// Trigger a digest to apply any updates done above
556+
$scope.$digest();
555557
});
556558
};
557559

test/navigation/vertical-navigation.spec.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe('Component: pfVerticalNavigation', function () {
1919
$compile(element)(scope);
2020

2121
scope.$digest();
22-
isolateScope = element.isolateScope();
22+
isolateScope = element.find("pf-vertical-navigation").isolateScope();
2323
};
2424

2525
beforeEach(function () {
@@ -697,6 +697,13 @@ describe('Component: pfVerticalNavigation', function () {
697697
wellDefinedItem.click();
698698
}).toThrow(new Error("uiSref is defined on item, but no $state has been injected. Did you declare a dependency on \"ui.router\" module in your app?"));
699699
});
700+
701+
it('should trigger a $digest when resizing', inject(function($window) {
702+
spyOn(isolateScope, '$digest');
703+
$window.innerWidth = 767;
704+
angular.element($window).triggerHandler('resize');
705+
expect(isolateScope.$digest).toHaveBeenCalled();
706+
}));
700707
});
701708

702709

@@ -749,7 +756,7 @@ describe('Directive: pfVerticalNavigation with ui.router', function () {
749756
$compile(element)(scope);
750757

751758
scope.$digest();
752-
isolateScope = element.isolateScope();
759+
isolateScope = element.find("pf-vertical-navigation").isolateScope();
753760
};
754761

755762
beforeEach(function () {

0 commit comments

Comments
 (0)