Skip to content

Commit 9cd85b8

Browse files
authored
Merge pull request #426 from rvsia/pf4wizardvalidating
fix(pf4): wizard disable button on validating
2 parents b9675ae + 01c49e4 commit 9cd85b8

File tree

5 files changed

+801
-397
lines changed

5 files changed

+801
-397
lines changed

packages/pf4-component-mapper/src/files/wizard/step-buttons.js

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,15 @@ import React from 'react';
22
import PropTypes from 'prop-types';
33
import { Button } from '@patternfly/react-core';
44
import selectNext from '@data-driven-forms/common/src/wizard/select-next';
5+
import { FormSpy } from '@data-driven-forms/react-form-renderer';
56

67
const SimpleNext = ({ nextStep, valid, handleNext, submit, nextLabel, getState }) => (
7-
<Button variant="primary" type="button" isDisabled={!valid} onClick={() => (valid ? handleNext(selectNext(nextStep, getState)) : submit())}>
8+
<Button
9+
variant="primary"
10+
type="button"
11+
isDisabled={!valid || getState().validating}
12+
onClick={() => (valid ? handleNext(selectNext(nextStep, getState)) : submit())}
13+
>
814
{nextLabel}
915
</Button>
1016
);
@@ -66,15 +72,19 @@ const WizardStepButtons = ({
6672
selectNext={selectNext}
6773
/>
6874
) : (
69-
<React.Fragment>
70-
<NextButton {...formOptions} handleNext={handleNext} nextStep={nextStep} nextLabel={next} submitLabel={submit} />
71-
<Button type="button" variant="secondary" isDisabled={disableBack} onClick={handlePrev}>
72-
{back}
73-
</Button>
74-
<Button type="button" variant="link" onClick={formOptions.onCancel}>
75-
{cancel}
76-
</Button>
77-
</React.Fragment>
75+
<FormSpy>
76+
{() => (
77+
<React.Fragment>
78+
<NextButton {...formOptions} handleNext={handleNext} nextStep={nextStep} nextLabel={next} submitLabel={submit} />
79+
<Button type="button" variant="secondary" isDisabled={disableBack} onClick={handlePrev}>
80+
{back}
81+
</Button>
82+
<Button type="button" variant="link" onClick={formOptions.onCancel}>
83+
{cancel}
84+
</Button>
85+
</React.Fragment>
86+
)}
87+
</FormSpy>
7888
)}
7989
</footer>
8090
);

0 commit comments

Comments
 (0)