@@ -7,6 +7,7 @@ import './wizard-styles.scss';
7
7
import get from 'lodash/get' ;
8
8
import set from 'lodash/set' ;
9
9
import flattenDeep from 'lodash/flattenDeep' ;
10
+ import { selectNext } from './step-buttons' ;
10
11
11
12
const DYNAMIC_WIZARD_TYPES = [ 'function' , 'object' ] ;
12
13
@@ -246,6 +247,29 @@ class Wizard extends React.Component {
246
247
< div className = { `pf-c-wizard ${ inModal ? '' : 'no-shadow' } ${ isCompactNav ? 'pf-m-compact-nav' : '' } ${ setFullWidth ? 'pf-m-full-width' : '' } ${ setFullHeight ? 'pf-m-full-height' : '' } ` }
247
248
role = "dialog"
248
249
aria-modal = { inModal ? 'true' : undefined }
250
+ onKeyDown = { e => {
251
+ if ( e . key === 'Enter' ) {
252
+ const isNotButton = e . target . type !== 'button' ;
253
+
254
+ if ( isNotButton ) {
255
+ e . preventDefault ( ) ;
256
+
257
+ const schemaNextStep = this . findCurrentStep ( this . state . activeStep ) . nextStep ;
258
+ const hasCustomButtons = this . findCurrentStep ( this . state . activeStep ) . buttons ;
259
+
260
+ let nextStep ;
261
+ if ( schemaNextStep ) {
262
+ nextStep = selectNext ( schemaNextStep , formOptions . getState ) ;
263
+ }
264
+
265
+ if ( formOptions . valid && nextStep && ! hasCustomButtons ) {
266
+ this . handleNext ( nextStep , formOptions . getRegisteredFields ) ;
267
+ } else if ( formOptions . valid && ! schemaNextStep && ! hasCustomButtons ) {
268
+ handleSubmit ( ) ;
269
+ }
270
+ }
271
+ }
272
+ } }
249
273
>
250
274
{ title && < WizardHeader
251
275
title = { title }
@@ -284,6 +308,7 @@ Wizard.propTypes = {
284
308
onSubmit : PropTypes . func . isRequired ,
285
309
onCancel : PropTypes . func ,
286
310
getRegisteredFields : PropTypes . func . isRequired ,
311
+ valid : PropTypes . bool . isRequired ,
287
312
} ) ,
288
313
fields : PropTypes . arrayOf ( PropTypes . shape ( {
289
314
stepKey : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . number ] ) . isRequired ,
0 commit comments