diff --git a/packages/patternfly-react/src/components/Wizard/Patterns/WizardPattern.js b/packages/patternfly-react/src/components/Wizard/Patterns/WizardPattern.js index b1300eb2d59..e013f21f846 100644 --- a/packages/patternfly-react/src/components/Wizard/Patterns/WizardPattern.js +++ b/packages/patternfly-react/src/components/Wizard/Patterns/WizardPattern.js @@ -14,6 +14,7 @@ const WizardPattern = ({ onNext, onBack, nextStepDisabled, + backStepDisabled, title, loadingTitle, loadingMessage, @@ -80,19 +81,20 @@ const WizardPattern = ({ const preventEnterTarget = targetStep.preventEnter || (stepBeforeTarget && stepBeforeTarget.isInvalid); - const nextStepClicked = newStepIndex === activeStepIndex + 1; + const nextStepClicked = newStepIndex > activeStepIndex; - return ( - preventExitActive || - preventEnterTarget || - (nextStepClicked && nextStepDisabled) - ); + return preventExitActive || preventEnterTarget || nextStepClicked + ? nextStepDisabled + : backStepDisabled; }; const activeStepStr = (activeStepIndex + 1).toString(); const prevStepUnreachable = - onFirstStep || activeStep.preventExit || getPrevStep().preventEnter; + backStepDisabled || + onFirstStep || + activeStep.preventExit || + getPrevStep().preventEnter; // nextStepUnreachable is still true onFinalStep, because the Next button turns into a Close button const nextStepUnreachable = nextStepDisabled || @@ -168,6 +170,7 @@ WizardPattern.propTypes = { closeText: PropTypes.string, steps: PropTypes.arrayOf(PropTypes.shape(wizardStepShape)), nextStepDisabled: PropTypes.bool, + backStepDisabled: PropTypes.bool, stepButtonsDisabled: PropTypes.bool, nextButtonRef: PropTypes.func, bodyHeader: PropTypes.node, @@ -191,6 +194,7 @@ WizardPattern.defaultProps = { closeText: 'Close', steps: [], nextStepDisabled: false, + backStepDisabled: false, stepButtonsDisabled: false, nextButtonRef: noop, bodyHeader: null,