From b579749ab89a5168b404cb7a883e55e977bddf89 Mon Sep 17 00:00:00 2001 From: Jeffrey Phillips Date: Fri, 20 Apr 2018 14:07:54 -0400 Subject: [PATCH] feat(wizard): Add ability to set initial focus component per page --- src/wizard/examples/wizard.js | 47 +++++++++++++++++++------- src/wizard/wizard-step.component.js | 27 +++++++++++++++ src/wizard/wizard-substep.component.js | 2 ++ src/wizard/wizard.component.js | 24 +++++++++++++ 4 files changed, 87 insertions(+), 13 deletions(-) diff --git a/src/wizard/examples/wizard.js b/src/wizard/examples/wizard.js index 20317bc8d..987fab6cf 100644 --- a/src/wizard/examples/wizard.js +++ b/src/wizard/examples/wizard.js @@ -78,17 +78,8 @@ - -
-

Wizards should make use of substeps consistently throughout (either using them or not using them). This is an example only.

- - - - - - -
-
+
+
@@ -97,7 +88,14 @@
- +
@@ -137,6 +135,21 @@
+ +
+ +
+

Wizards should make use of substeps consistently throughout (either using them or not using them). This is an example only.

+ + + + + + +
+
+
+
@@ -262,7 +275,7 @@ $scope.reviewTemplate = "review-template.html"; $scope.detailsGeneralComplete = false; - + $scope.focusSelectors = ['#new-name']; $scope.onShow = function() { }; $scope.updateName = function() { @@ -288,6 +301,14 @@ } ]); + angular.module('patternfly.wizard').controller('SecondStepController', ['$rootScope', '$scope', + function ($rootScope, $scope) { + 'use strict'; + + $scope.focusSelectors = ['.invalid-classname', '#step-two-new-lorem']; + } + ]); + angular.module('patternfly.wizard').controller('SummaryController', ['$rootScope', '$scope', '$timeout', function ($rootScope, $scope, $timeout) { 'use strict'; diff --git a/src/wizard/wizard-step.component.js b/src/wizard/wizard-step.component.js index ccfb75a14..83c55bc88 100644 --- a/src/wizard/wizard-step.component.js +++ b/src/wizard/wizard-step.component.js @@ -20,6 +20,7 @@ * @param {string=} description The step description (optional) * @param {object} wizardData Data passed to the step that is shared by the entire wizard * @param {function()=} onShow The function called when the wizard shows this step + * @param {object=} focusSelectors Array of selectors to be used (in the order given) to find the initial focus component for the page * @param {boolean=} showReview Indicates whether review information should be displayed for this step when the review step is reached * @param {boolean=} showReviewDetails Indicators whether the review information should be expanded by default when the review step is reached * @param {string=} reviewTemplate The template that should be used for the review details screen @@ -41,6 +42,7 @@ angular.module('patternfly.wizard').component('pfWizardStep', { description: '@', wizardData: '=', onShow: '=?', + focusSelectors: '