@@ -19620,17 +19620,8 @@ angular.module('patternfly.views').component('pfEmptyState', {
19620
19620
</form>
19621
19621
</pf-wizard-substep>
19622
19622
</pf-wizard-step>
19623
- <pf-wizard-step step-title="Second Step" next-tooltip="secondStepNextTooltip" prev-tooltip="secondStepPrevTooltip" substeps="false" step-id="configuration" step-priority="1" show-review="true" review-template="review-second-template.html" >
19624
- <form class="form-horizontal">
19625
- <h3>Wizards should make use of substeps consistently throughout (either using them or not using them). This is an example only.</h3>
19626
- <pf-form-group pf-label="Lorem" pf-label-class="col-sm-3 col-md-2" pf-input-class="col-sm-9 col-md-10" >
19627
- <input id="new-lorem" name="lorem" ng-model="data.lorem" type="text"/>
19628
- </pf-form-group>
19629
- <pf-form-group pf-label="Ipsum" pf-label-class="col-sm-3 col-md-2" pf-input-class="col-sm-9 col-md-10" >
19630
- <input id="new-ipsum" name="ipsum" ng-model="data.ipsum" type="text" />
19631
- </pf-form-group>
19632
- </form>
19633
- </pf-wizard-step>
19623
+ <div ng-include="'second-step.html'">
19624
+ </div>
19634
19625
<pf-wizard-step step-title="Review" next-tooltip="reviewStepNextTooltip" prev-tooltip="reviewStepPrevTooltip" substeps="true" step-id="review" step-priority="2">
19635
19626
<div ng-include="'summary.html'"></div>
19636
19627
<div ng-include="'deployment.html'"></div>
@@ -19639,7 +19630,14 @@ angular.module('patternfly.views').component('pfEmptyState', {
19639
19630
</file>
19640
19631
<file name="detail-page.html">
19641
19632
<div ng-controller="DetailsGeneralController">
19642
- <pf-wizard-substep step-title="General" next-enabled="detailsGeneralComplete" step-id="details-general" step-priority="0" on-show="onShow" review-template="{{reviewTemplate}}" show-review-details="true">
19633
+ <pf-wizard-substep step-title="General"
19634
+ next-enabled="detailsGeneralComplete"
19635
+ step-id="details-general"
19636
+ step-priority="0"
19637
+ on-show="onShow"
19638
+ focus-selectors="focusSelectors"
19639
+ review-template="{{reviewTemplate}}"
19640
+ show-review-details="true">
19643
19641
<form class="form-horizontal">
19644
19642
<pf-form-group pf-label="Name" pf-label-class="col-sm-3 col-md-2" pf-input-class="col-sm-9 col-md-10" required>
19645
19643
<input id="new-name" name="name" ng-model="data.name" type="text" ng-change="updateName()" required/>
@@ -19679,6 +19677,21 @@ angular.module('patternfly.views').component('pfEmptyState', {
19679
19677
</form>
19680
19678
</div>
19681
19679
</file>
19680
+ <file name="second-step.html">
19681
+ <div ng-controller="SecondStepController">
19682
+ <pf-wizard-step focus-selectors="focusSelectors" step-title="Second Step" next-tooltip="secondStepNextTooltip" prev-tooltip="secondStepPrevTooltip" substeps="false" step-id="configuration" step-priority="1" show-review="true" review-template="review-second-template.html" >
19683
+ <form class="form-horizontal">
19684
+ <h3>Wizards should make use of substeps consistently throughout (either using them or not using them). This is an example only.</h3>
19685
+ <pf-form-group pf-label="Lorem" pf-label-class="col-sm-3 col-md-2" pf-input-class="col-sm-9 col-md-10" >
19686
+ <input id="step-two-new-lorem" name="lorem" ng-model="data.lorem" type="text"/>
19687
+ </pf-form-group>
19688
+ <pf-form-group pf-label="Ipsum" pf-label-class="col-sm-3 col-md-2" pf-input-class="col-sm-9 col-md-10" >
19689
+ <input id="step-two-new-ipsum" name="ipsum" ng-model="data.ipsum" type="text" />
19690
+ </pf-form-group>
19691
+ </form>
19692
+ </pf-wizard-step>
19693
+ </div>
19694
+ </file>
19682
19695
<file name="summary.html">
19683
19696
<div ng-controller="SummaryController">
19684
19697
<pf-wizard-substep step-title="Summary" step-id="review-summary" step-priority="0" next-enabled="true" prev-enabled="true" ok-to-nav-away="true" wz-disabled="false" on-show="onShow">
@@ -19804,7 +19817,7 @@ angular.module('patternfly.views').component('pfEmptyState', {
19804
19817
19805
19818
$scope.reviewTemplate = "review-template.html";
19806
19819
$scope.detailsGeneralComplete = false;
19807
-
19820
+ $scope.focusSelectors = ['#new-name'];
19808
19821
$scope.onShow = function() { };
19809
19822
19810
19823
$scope.updateName = function() {
@@ -19830,6 +19843,14 @@ angular.module('patternfly.views').component('pfEmptyState', {
19830
19843
}
19831
19844
]);
19832
19845
19846
+ angular.module('patternfly.wizard').controller('SecondStepController', ['$rootScope', '$scope',
19847
+ function ($rootScope, $scope) {
19848
+ 'use strict';
19849
+
19850
+ $scope.focusSelectors = ['.invalid-classname', '#step-two-new-lorem'];
19851
+ }
19852
+ ]);
19853
+
19833
19854
angular.module('patternfly.wizard').controller('SummaryController', ['$rootScope', '$scope', '$timeout',
19834
19855
function ($rootScope, $scope, $timeout) {
19835
19856
'use strict';
@@ -20062,6 +20083,7 @@ angular.module('patternfly.wizard').component('pfWizardReviewPage', {
20062
20083
* @param {string=} description The step description (optional)
20063
20084
* @param {object} wizardData Data passed to the step that is shared by the entire wizard
20064
20085
* @param {function()=} onShow The function called when the wizard shows this step
20086
+ * @param {object=} focusSelectors Array of selectors to be used (in the order given) to find the initial focus component for the page
20065
20087
* @param {boolean=} showReview Indicates whether review information should be displayed for this step when the review step is reached
20066
20088
* @param {boolean=} showReviewDetails Indicators whether the review information should be expanded by default when the review step is reached
20067
20089
* @param {string=} reviewTemplate The template that should be used for the review details screen
@@ -20083,6 +20105,7 @@ angular.module('patternfly.wizard').component('pfWizardStep', {
20083
20105
description: '@',
20084
20106
wizardData: '=',
20085
20107
onShow: '=?',
20108
+ focusSelectors: '<?',
20086
20109
showReview: '@?',
20087
20110
showReviewDetails: '@?',
20088
20111
reviewTemplate: '@?'
@@ -20259,6 +20282,8 @@ angular.module('patternfly.wizard').component('pfWizardStep', {
20259
20282
};
20260
20283
20261
20284
ctrl.goTo = function (step) {
20285
+ var focusElement = null;
20286
+
20262
20287
if (ctrl.wizard.isWizardDone() || !step.okToNavAway || step === ctrl.selectedStep) {
20263
20288
return;
20264
20289
}
@@ -20274,6 +20299,29 @@ angular.module('patternfly.wizard').component('pfWizardStep', {
20274
20299
ctrl.selectedStep.onShow();
20275
20300
}
20276
20301
20302
+ // Give time for onShow to do its thing (maybe update the selectors), then time to display the elements
20303
+ $timeout(function () {
20304
+ if (step.focusSelectors) {
20305
+ _.find(step.focusSelectors, function (selector) {
20306
+ return focusElement = document.querySelector(selector);
20307
+ });
20308
+ }
20309
+
20310
+ // Default to next button if it is enabled
20311
+ if (!focusElement && step.nextEnabled) {
20312
+ focusElement = document.querySelector('.wizard-pf-next');
20313
+ }
20314
+
20315
+ // Use cancel button if we haven't found anything else to set focus on
20316
+ if (!focusElement) {
20317
+ focusElement = document.querySelector('.wizard-pf-cancel');
20318
+ }
20319
+
20320
+ if (focusElement) {
20321
+ focusElement.focus();
20322
+ }
20323
+ }, 300);
20324
+
20277
20325
ctrl.currentStep = step.stepTitle;
20278
20326
20279
20327
firstRun = false;
@@ -20381,6 +20429,7 @@ angular.module('patternfly.wizard').component('pfWizardStep', {
20381
20429
* @param {string=} description The step description
20382
20430
* @param {object} wizardData Data passed to the step that is shared by the entire wizard
20383
20431
* @param {function()=} onShow The function called when the wizard shows this step
20432
+ * @param {object=} focusSelectors Array of selectors to be used (in the order given) to find the initial focus component for the page
20384
20433
* @param {boolean=} showReviewDetails Indicators whether the review information should be expanded by default when the review step is reached
20385
20434
* @param {string=} reviewTemplate The template that should be used for the review details screen
20386
20435
*/
@@ -20398,6 +20447,7 @@ angular.module('patternfly.wizard').component('pfWizardSubstep', {
20398
20447
description: '@',
20399
20448
wizardData: '=',
20400
20449
onShow: '=?',
20450
+ focusSelectors: '<?',
20401
20451
showReviewDetails: '@?',
20402
20452
reviewTemplate: '@?'
20403
20453
},
@@ -20641,6 +20691,8 @@ angular.module('patternfly.wizard').component('pfWizardSubstep', {
20641
20691
};
20642
20692
20643
20693
ctrl.goTo = function (step, resetStepNav) {
20694
+ var focusElement = null;
20695
+
20644
20696
if (ctrl.wizardDone || (ctrl.selectedStep && !ctrl.selectedStep.okToNavAway) || step === ctrl.selectedStep) {
20645
20697
return;
20646
20698
}
@@ -20659,6 +20711,28 @@ angular.module('patternfly.wizard').component('pfWizardSubstep', {
20659
20711
if (angular.isFunction(step.onShow)) {
20660
20712
step.onShow();
20661
20713
}
20714
+ // Give time for onShow to do its thing (maybe update the selectors), then time to display the elements
20715
+ $timeout(function () {
20716
+ if (step.focusSelectors) {
20717
+ _.find(step.focusSelectors, function (selector) {
20718
+ return focusElement = document.querySelector(selector);
20719
+ });
20720
+ }
20721
+
20722
+ // Default to next button if it is enabled
20723
+ if (!focusElement && step.nextEnabled) {
20724
+ focusElement = document.querySelector('.wizard-pf-next');
20725
+ }
20726
+
20727
+ // Use cancel button if we haven't found anything else to set focus on
20728
+ if (!focusElement) {
20729
+ focusElement = document.querySelector('.wizard-pf-cancel');
20730
+ }
20731
+
20732
+ if (focusElement) {
20733
+ focusElement.focus();
20734
+ }
20735
+ }, 300);
20662
20736
}, 100);
20663
20737
20664
20738
// Make sure current step is not undefined
0 commit comments