diff --git a/horizon/static/framework/widgets/wizard/wizard.controller.js b/horizon/static/framework/widgets/wizard/wizard.controller.js index 6cdacfcc32..a92b530ffd 100644 --- a/horizon/static/framework/widgets/wizard/wizard.controller.js +++ b/horizon/static/framework/widgets/wizard/wizard.controller.js @@ -78,15 +78,8 @@ from: $scope.currentIndex, to: index }); - /** - * Toggle help icon button if a step's helpUrl is not defined - */ + toggleHelpBtn(index); /*eslint-disable angular/controller-as */ - if (angular.isUndefined(steps[index].helpUrl)) { - $scope.hideHelpBtn = true; - } else { - $scope.hideHelpBtn = false; - } $scope.currentIndex = index; $scope.openHelp = false; /*eslint-enable angular/controller-as*/ @@ -123,12 +116,24 @@ function onInitSuccess() { $scope.$broadcast(wizardEvents.ON_INIT_SUCCESS); + if (steps.length > 0) { + toggleHelpBtn(0); + } } function onInitError() { $scope.$broadcast(wizardEvents.ON_INIT_ERROR); } + function toggleHelpBtn(index) { + // Toggle help icon button if a step's helpUrl is not defined + if (angular.isUndefined(steps[index].helpUrl)) { + $scope.hideHelpBtn = true; + } else { + $scope.hideHelpBtn = false; + } + } + /** * Each step in the workflow can provide an optional `checkReadiness` * method, which should return a promise. When this method is provided diff --git a/horizon/static/framework/widgets/wizard/wizard.spec.js b/horizon/static/framework/widgets/wizard/wizard.spec.js index 97df17ff90..7320ff5276 100644 --- a/horizon/static/framework/widgets/wizard/wizard.spec.js +++ b/horizon/static/framework/widgets/wizard/wizard.spec.js @@ -69,7 +69,7 @@ steps: [ {}, {}, {} ] }; $scope.$apply(); - expect(angular.element(element).find('.help-toggle').hasClass('ng-hide')).toBe(false); + expect(angular.element(element).find('.help-toggle').hasClass('ng-hide')).toBe(true); $scope.workflow.steps[1] = {}; $scope.switchTo(1);