Skip to content

Commit

Permalink
Merge pull request #2963 from glific/fix/form-layout
Browse files Browse the repository at this point in the history
Fixed a bug in form layout
  • Loading branch information
akanshaaa19 authored Jul 8, 2024
2 parents 37168cf + dddf43c commit b933396
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 2 additions & 3 deletions src/containers/Form/FormLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,10 @@ export const FormLayout = ({
validationSchema: validationSchema,
enableReinitialize: true,
onSubmit: (values, { setErrors }) => {
setCustomError({ setErrors });
if (confirmationState?.show) {
setShowConfirmationDialog(true);
} else {
onSaveButtonClick(formik.errors);
setCustomError({ setErrors });
saveHandler(values);
}
},
Expand Down Expand Up @@ -562,6 +561,7 @@ export const FormLayout = ({
variant="contained"
color="primary"
onClick={() => {
onSaveButtonClick(formik.errors);
formik.submitForm();
}}
className={styles.Button}
Expand Down Expand Up @@ -641,7 +641,6 @@ export const FormLayout = ({
<DialogBox
title={confirmationState?.title || 'Are you sure you want to proceed?'}
handleOk={() => {
onSaveButtonClick(formik.errors);
saveHandler(formik.values);
}}
handleCancel={() => setShowConfirmationDialog(false)}
Expand Down
5 changes: 2 additions & 3 deletions src/containers/Template/Form/HSM/HSM.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ describe('Add mode', () => {
});

const { queryByText } = within(container.querySelector('form') as HTMLElement);
const button: any = queryByText('Submit for Approval');
await user.click(button);
fireEvent.click(screen.getByTestId('submitActionButton'));

// we should have 2 errors
await waitFor(() => {
Expand All @@ -63,7 +62,7 @@ describe('Add mode', () => {
},
});

await user.click(button);
fireEvent.click(screen.getByTestId('submitActionButton'));

// we should still have 2 errors
await waitFor(() => {
Expand Down

0 comments on commit b933396

Please sign in to comment.