@@ -183,6 +183,21 @@ class Wizard extends React.Component {
183183 return schema ;
184184 } ;
185185
186+ handleSubmitFinal = ( ) => this . props . formOptions . onSubmit (
187+ this . handleSubmit (
188+ this . props . formOptions . getState ( ) . values ,
189+ [ ...this . state . prevSteps , this . state . activeStep ] ,
190+ this . props . formOptions . getRegisteredFields ,
191+ ) ,
192+ this . props . formOptions
193+ ) ;
194+
195+ setPrevSteps = ( ) => this . setState ( ( prevState ) => ( {
196+ navSchema : this . createSchema ( { currentIndex : this . state . activeStepIndex } ) ,
197+ prevSteps : prevState . prevSteps . slice ( 0 , this . state . activeStepIndex ) ,
198+ maxStepIndex : this . state . activeStepIndex ,
199+ } ) )
200+
186201 render ( ) {
187202 if ( this . state . loading ) {
188203 return null ;
@@ -205,22 +220,12 @@ class Wizard extends React.Component {
205220 } = this . props ;
206221 const { activeStepIndex, navSchema, maxStepIndex, isDynamic } = this . state ;
207222
208- const handleSubmit = ( ) =>
209- formOptions . onSubmit (
210- this . handleSubmit (
211- formOptions . getState ( ) . values ,
212- [ ...this . state . prevSteps , this . state . activeStep ] ,
213- formOptions . getRegisteredFields ,
214- ) ,
215- formOptions
216- ) ;
217-
218223 const currentStep = (
219224 < WizardStep
220225 { ...this . findCurrentStep ( this . state . activeStep ) }
221226 formOptions = { {
222227 ...formOptions ,
223- handleSubmit,
228+ handleSubmit : this . handleSubmitFinal ,
224229 } }
225230 buttonLabels = { buttonLabels }
226231 FieldProvider = { FieldProvider }
@@ -233,7 +238,7 @@ class Wizard extends React.Component {
233238 < div className = { `pf-c-wizard ${ inModal ? '' : 'no-shadow' } ${ isCompactNav ? 'pf-m-compact-nav' : '' } ${ setFullWidth ? 'pf-m-full-width' : '' } ${ setFullHeight ? 'pf-m-full-height' : '' } ` }
234239 role = "dialog"
235240 aria-modal = { inModal ? 'true' : undefined }
236- onKeyDown = { e => handleEnter ( e , formOptions , this . state . activeStep , this . findCurrentStep , this . handleNext , handleSubmit ) }
241+ onKeyDown = { e => handleEnter ( e , formOptions , this . state . activeStep , this . findCurrentStep , this . handleNext , this . handleSubmitFinal ) }
237242 >
238243 { title && < WizardHeader
239244 title = { title }
@@ -253,11 +258,7 @@ class Wizard extends React.Component {
253258 crossroads = { crossroads }
254259 isDynamic = { isDynamic }
255260 values = { values }
256- setPrevSteps = { ( ) => this . setState ( ( prevState ) => ( {
257- navSchema : this . createSchema ( { currentIndex : activeStepIndex } ) ,
258- prevSteps : prevState . prevSteps . slice ( 0 , activeStepIndex ) ,
259- maxStepIndex : activeStepIndex ,
260- } ) ) }
261+ setPrevSteps = { this . setPrevSteps }
261262 />
262263 ) }
263264 </ FormSpyProvider >
0 commit comments