Skip to content

Commit

Permalink
Fix: Test Connection button disabled after save (getredash#5666)
Browse files Browse the repository at this point in the history
  • Loading branch information
JyothiGandi authored Feb 1, 2022
1 parent 26ac8ab commit ea07e7e
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions client/app/components/dynamic-form/DynamicForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ export default function DynamicForm({
onSubmit,
}) {
const [isSubmitting, setIsSubmitting] = useState(false);
const [isTouched, setIsTouched] = useState(false);
const [showExtraFields, setShowExtraFields] = useState(defaultShowExtraFields);
const [form] = Form.useForm();
const extraFields = filter(fields, { extra: true });
Expand All @@ -163,9 +164,8 @@ export default function DynamicForm({
onSubmit(
values,
msg => {
const { setFieldsValue, getFieldsValue } = form;
setIsSubmitting(false);
setFieldsValue(getFieldsValue()); // reset form touched state
setIsTouched(false); // reset form touched state
notification.success(msg);
},
msg => {
Expand All @@ -174,7 +174,7 @@ export default function DynamicForm({
}
);
},
[form, fields, onSubmit]
[fields, onSubmit]
);

const handleFinishFailed = useCallback(
Expand All @@ -187,6 +187,9 @@ export default function DynamicForm({
return (
<Form
form={form}
onFieldsChange={() => {
setIsTouched(true);
}}
id={id}
className="dynamic-form"
layout="vertical"
Expand Down Expand Up @@ -216,7 +219,7 @@ export default function DynamicForm({
{saveText}
</Button>
)}
<DynamicFormActions actions={actions} isFormDirty={form.isFieldsTouched()} />
<DynamicFormActions actions={actions} isFormDirty={isTouched} />
</Form>
);
}
Expand Down

0 comments on commit ea07e7e

Please sign in to comment.