From 32d0e7361e35b005af18bb11ed50dfd58239eb79 Mon Sep 17 00:00:00 2001 From: Alec M Date: Mon, 9 Dec 2024 13:50:55 -0500 Subject: [PATCH] fix: Enter button enables double submit --- .../DataSubmissions/CreateDataSubmissionDialog.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/DataSubmissions/CreateDataSubmissionDialog.tsx b/src/components/DataSubmissions/CreateDataSubmissionDialog.tsx index 06230e121..dcbbff7bb 100644 --- a/src/components/DataSubmissions/CreateDataSubmissionDialog.tsx +++ b/src/components/DataSubmissions/CreateDataSubmissionDialog.tsx @@ -212,7 +212,7 @@ const CreateDataSubmissionDialog: FC = ({ onCreate }) => { register, control, watch, - formState: { errors }, + formState: { isSubmitting, errors }, setValue, reset, } = useForm({ @@ -298,8 +298,8 @@ const CreateDataSubmissionDialog: FC = ({ onCreate }) => { dbGaPID, intention, dataType, - }: CreateSubmissionInput) => { - await createDataSubmission({ + }: CreateSubmissionInput) => + createDataSubmission({ variables: { studyID, dataCommons, @@ -328,10 +328,9 @@ const CreateDataSubmissionDialog: FC = ({ onCreate }) => { setError(true); Logger.error("Error creating submission", e); }); - }; - const onSubmit: SubmitHandler = (data) => { - createSubmission(data); + const onSubmit: SubmitHandler = async (data) => { + await createSubmission(data); }; const validateEmpty = (value: string): string | null => @@ -564,6 +563,7 @@ const CreateDataSubmissionDialog: FC = ({ onCreate }) => { tabIndex={0} id="createSubmissionDialogCreateButton" form="create-submission-dialog-form" + disabled={isSubmitting} > Create