@@ -183,6 +183,21 @@ class Wizard extends React.Component {
183
183
return schema ;
184
184
} ;
185
185
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
+
186
201
render ( ) {
187
202
if ( this . state . loading ) {
188
203
return null ;
@@ -205,22 +220,12 @@ class Wizard extends React.Component {
205
220
} = this . props ;
206
221
const { activeStepIndex, navSchema, maxStepIndex, isDynamic } = this . state ;
207
222
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
-
218
223
const currentStep = (
219
224
< WizardStep
220
225
{ ...this . findCurrentStep ( this . state . activeStep ) }
221
226
formOptions = { {
222
227
...formOptions ,
223
- handleSubmit,
228
+ handleSubmit : this . handleSubmitFinal ,
224
229
} }
225
230
buttonLabels = { buttonLabels }
226
231
FieldProvider = { FieldProvider }
@@ -233,7 +238,7 @@ class Wizard extends React.Component {
233
238
< div className = { `pf-c-wizard ${ inModal ? '' : 'no-shadow' } ${ isCompactNav ? 'pf-m-compact-nav' : '' } ${ setFullWidth ? 'pf-m-full-width' : '' } ${ setFullHeight ? 'pf-m-full-height' : '' } ` }
234
239
role = "dialog"
235
240
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 ) }
237
242
>
238
243
{ title && < WizardHeader
239
244
title = { title }
@@ -253,11 +258,7 @@ class Wizard extends React.Component {
253
258
crossroads = { crossroads }
254
259
isDynamic = { isDynamic }
255
260
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 }
261
262
/>
262
263
) }
263
264
</ FormSpyProvider >
0 commit comments