Skip to content

Commit cfab606

Browse files
authored
Merge pull request #1376 from data-driven-forms/pf4-modal-props
Add ModalProps to pf4 wizard.
2 parents 7505ea2 + 9d34b78 commit cfab606

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

packages/pf4-component-mapper/src/wizard/wizard.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { ReactNode } from "react";
22
import { Field, AnyObject } from "@data-driven-forms/react-form-renderer";
3+
import { ModalProps } from "@patternfly/react-core";
34

45
export interface WizardButtonLabels {
56
submit?: ReactNode;
@@ -92,6 +93,7 @@ export interface WizardProps {
9293
hasNoBodyPadding?: boolean;
9394
navAriaLabel?: string;
9495
StepTemplate?: React.ComponentType<StepTemplateProps>;
96+
ModalProps?: ModalProps
9597
}
9698

9799
declare const Wizard: React.ComponentType<WizardProps>;

packages/pf4-component-mapper/src/wizard/wizard.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const WizardInternal = ({
4444
StepTemplate,
4545
className,
4646
conditionalSubmitFlag,
47+
ModalProps = {},
4748
...rest
4849
}) => {
4950
const {
@@ -71,7 +72,10 @@ const WizardInternal = ({
7172
}, [inModal]);
7273

7374
useEffect(() => {
74-
if (state.container) {
75+
if (ModalProps.appendTo) {
76+
// override with default append to
77+
dispatch({ type: 'finishLoading' });
78+
} else if (state.container) {
7579
document.body.appendChild(state.container);
7680
dispatch({ type: 'finishLoading' });
7781
}
@@ -88,7 +92,7 @@ const WizardInternal = ({
8892
}
8993

9094
return (
91-
<Modal inModal={inModal} container={state.container} aria-labelledby={rest.name}>
95+
<Modal inModal={inModal} container={state.container} aria-labelledby={rest.name} {...ModalProps}>
9296
<div
9397
tabIndex={inModal ? 0 : null}
9498
className={`pf-c-wizard ${inModal ? '' : 'no-shadow'} ddorg__pf4-component-mapper__wizard ${className ? className : ''}`}
@@ -179,6 +183,7 @@ WizardInternal.propTypes = {
179183
StepTemplate: PropTypes.elementType,
180184
className: PropTypes.string,
181185
conditionalSubmitFlag: PropTypes.string,
186+
ModalProps: PropTypes.object,
182187
};
183188

184189
const defaultLabels = {

packages/react-renderer-demo/src/doc-components/examples-texts/pf4/wizard.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Don't forget hide form controls by setting \`showFormControls\` to \`false\` as
1717
|showTitles|bool|undefined|If true, step titles will be shown in the wizard body|
1818
|crossroads|array|undefined|Array of field names, which change next steps|
1919
|StepTemplate|componenr|DefaultStepTemplate|Custom component for rendering wizard body content.|
20+
|ModalProps|PF4 Modal props object. Used to customize the Modal element if `inModal` is true|
2021

2122
Also accepts these props from the original component: `titleId`, `descriptionId`, `hideClose`, `hasNoBodyPadding`, `navAriaLabel` and `closeButtonAriaLabel`.
2223

0 commit comments

Comments
 (0)