11import React , { useReducer , useEffect , useContext } from 'react' ;
2- import { createPortal } from 'react-dom' ;
32import PropTypes from 'prop-types' ;
43import { FormSpy , WizardContext } from '@data-driven-forms/react-form-renderer' ;
54import Wizard from '@data-driven-forms/common/src/wizard/wizard' ;
65
7- import { Bullseye , Backdrop , WizardNav , WizardHeader } from '@patternfly/react-core' ;
6+ import { WizardNav , WizardHeader , Modal as PF4Modal } from '@patternfly/react-core' ;
87
98import WizardStep from './wizard/wizard-step' ;
109import './wizard/wizard-styles.scss' ;
@@ -13,17 +12,20 @@ import WizardNavigation from './wizard/wizard-nav';
1312import reducer from './wizard/reducer' ;
1413import WizardToggle from './wizard/wizard-toggle' ;
1514
16- const Modal = ( { children, container, inModal } ) =>
17- inModal
18- ? createPortal (
19- < Backdrop >
20- < Bullseye >
21- < div className = "pf-c-modal-box pf-m-lg" > { children } </ div >
22- </ Bullseye >
23- </ Backdrop > ,
24- container
25- )
26- : children ;
15+ const Modal = ( { children, container, inModal, ...rest } ) =>
16+ inModal ? (
17+ < PF4Modal variant = "large" isOpen showClose = { false } hasNoBodyWrapper appendTo = { container } { ...rest } >
18+ { children }
19+ </ PF4Modal >
20+ ) : (
21+ children
22+ ) ;
23+
24+ Modal . propTypes = {
25+ children : PropTypes . node ,
26+ container : PropTypes . instanceOf ( Element ) ,
27+ inModal : PropTypes . bool
28+ } ;
2729
2830const WizardInternal = ( {
2931 inModal,
@@ -85,12 +87,18 @@ const WizardInternal = ({
8587 }
8688
8789 return (
88- < Modal inModal = { inModal } container = { state . container } >
90+ < Modal inModal = { inModal } container = { state . container } aria-labelledby = { rest . name } >
8991 < div
9092 className = { `pf-c-wizard ${ inModal ? '' : 'no-shadow' } ddorg__pf4-component-mapper__wizard ${ className ? className : '' } ` }
9193 role = "dialog"
9294 aria-modal = { inModal ? 'true' : undefined }
93- onKeyDown = { onKeyDown }
95+ onKeyDown = { ( e ) => {
96+ onKeyDown ( e ) ;
97+
98+ if ( e . key === 'Escape' && inModal ) {
99+ formOptions . onCancel ( ) ;
100+ }
101+ } }
94102 { ...rest }
95103 >
96104 { title && (
0 commit comments