@@ -19,6 +19,7 @@ interface NextButtonProps {
1919 handleSubmit : ( ) => void ;
2020 submitLabel : string ;
2121 conditionalSubmitFlag ?: any ;
22+ wizardFields ?: Array < { name : string ; isProgressAfterSubmissionStep ?: boolean } > ;
2223}
2324
2425const NextButton : React . FC < NextButtonProps > = ( {
@@ -30,15 +31,32 @@ const NextButton: React.FC<NextButtonProps> = ({
3031 handleSubmit,
3132 submitLabel,
3233 conditionalSubmitFlag,
34+ wizardFields,
3335} ) => {
3436 const nextResult = nextStep ? selectNext ( nextStep , getState ) : nextStep ;
35- const progressNext = nextResult !== conditionalSubmitFlag && nextStep ;
37+ const isNextStepProgressAfterSubmission = Boolean (
38+ wizardFields ?. find ( ( f ) => f . name === nextResult ) ?. isProgressAfterSubmissionStep
39+ ) ;
40+ const progressNext =
41+ nextStep && nextResult !== conditionalSubmitFlag && ! isNextStepProgressAfterSubmission ;
42+
43+ const onClick = ( ) => {
44+ if ( progressNext ) {
45+ handleNext ( selectNext ( nextStep , getState ) ) ;
46+ } else {
47+ handleSubmit ( ) ;
48+ if ( isNextStepProgressAfterSubmission && nextResult ) {
49+ handleNext ( nextResult ) ;
50+ }
51+ }
52+ } ;
53+
3654 return (
3755 < Button
3856 variant = "primary"
3957 type = "button"
4058 isDisabled = { ! valid || getState ( ) . validating }
41- onClick = { ( ) => ( progressNext ? handleNext ( selectNext ( nextStep , getState ) ) : handleSubmit ( ) ) }
59+ onClick = { onClick }
4260 >
4361 { progressNext ? nextLabel : submitLabel }
4462 </ Button >
@@ -68,6 +86,7 @@ const WizardStepButtons: React.FC<WizardStepButtonsProps> = ({
6886 buttonLabels : { cancel, submit, back, next } ,
6987 formOptions,
7088 conditionalSubmitFlag,
89+ wizardFields,
7190} ) => (
7291 < footer className = { `pf-v6-c-wizard__footer ${ buttonsClassName ? buttonsClassName : '' } ` } >
7392 < ActionList >
@@ -80,7 +99,15 @@ const WizardStepButtons: React.FC<WizardStepButtonsProps> = ({
8099 buttonsClassName = { buttonsClassName }
81100 buttonLabels = { { cancel, submit, back, next } }
82101 renderNextButton = { ( args : any ) => (
83- < NextButton { ...formOptions } handleNext = { handleNext } nextStep = { nextStep } nextLabel = { next } submitLabel = { submit } { ...args } />
102+ < NextButton
103+ { ...formOptions }
104+ handleNext = { handleNext }
105+ nextStep = { nextStep }
106+ nextLabel = { next }
107+ submitLabel = { submit }
108+ wizardFields = { wizardFields }
109+ { ...args }
110+ />
84111 ) }
85112 selectNext = { selectNext }
86113 />
@@ -90,14 +117,15 @@ const WizardStepButtons: React.FC<WizardStepButtonsProps> = ({
90117 < React . Fragment >
91118 < ActionListGroup >
92119 < ActionListItem >
93- < NextButton
94- { ...formOptions }
95- conditionalSubmitFlag = { conditionalSubmitFlag }
96- handleNext = { handleNext }
97- nextStep = { nextStep }
98- nextLabel = { next }
99- submitLabel = { submit }
100- />
120+ < NextButton
121+ { ...formOptions }
122+ conditionalSubmitFlag = { conditionalSubmitFlag }
123+ handleNext = { handleNext }
124+ nextStep = { nextStep }
125+ nextLabel = { next }
126+ submitLabel = { submit }
127+ wizardFields = { wizardFields }
128+ />
101129 </ ActionListItem >
102130 < ActionListItem >
103131 < Button type = "button" variant = "secondary" isDisabled = { disableBack } onClick = { handlePrev } >
0 commit comments