1
1
import React , { useReducer , useEffect , useContext } from 'react' ;
2
- import { createPortal } from 'react-dom' ;
3
2
import PropTypes from 'prop-types' ;
4
3
import { FormSpy , WizardContext } from '@data-driven-forms/react-form-renderer' ;
5
4
import Wizard from '@data-driven-forms/common/src/wizard/wizard' ;
6
5
7
- import { Bullseye , Backdrop , WizardNav , WizardHeader } from '@patternfly/react-core' ;
6
+ import { WizardNav , WizardHeader , Modal as PF4Modal } from '@patternfly/react-core' ;
8
7
9
8
import WizardStep from './wizard/wizard-step' ;
10
9
import './wizard/wizard-styles.scss' ;
@@ -13,17 +12,20 @@ import WizardNavigation from './wizard/wizard-nav';
13
12
import reducer from './wizard/reducer' ;
14
13
import WizardToggle from './wizard/wizard-toggle' ;
15
14
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
+ } ;
27
29
28
30
const WizardInternal = ( {
29
31
inModal,
@@ -85,12 +87,18 @@ const WizardInternal = ({
85
87
}
86
88
87
89
return (
88
- < Modal inModal = { inModal } container = { state . container } >
90
+ < Modal inModal = { inModal } container = { state . container } aria-labelledby = { rest . name } >
89
91
< div
90
92
className = { `pf-c-wizard ${ inModal ? '' : 'no-shadow' } ddorg__pf4-component-mapper__wizard ${ className ? className : '' } ` }
91
93
role = "dialog"
92
94
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
+ } }
94
102
{ ...rest }
95
103
>
96
104
{ title && (
0 commit comments