Skip to content

Commit

Permalink
fix: Enter button enables double submit
Browse files Browse the repository at this point in the history
  • Loading branch information
amattu2 committed Dec 9, 2024
1 parent 26aab58 commit 32d0e73
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/components/DataSubmissions/CreateDataSubmissionDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ const CreateDataSubmissionDialog: FC<Props> = ({ onCreate }) => {
register,
control,
watch,
formState: { errors },
formState: { isSubmitting, errors },
setValue,
reset,
} = useForm<CreateSubmissionInput>({
Expand Down Expand Up @@ -298,8 +298,8 @@ const CreateDataSubmissionDialog: FC<Props> = ({ onCreate }) => {
dbGaPID,
intention,
dataType,
}: CreateSubmissionInput) => {
await createDataSubmission({
}: CreateSubmissionInput) =>
createDataSubmission({
variables: {
studyID,
dataCommons,
Expand Down Expand Up @@ -328,10 +328,9 @@ const CreateDataSubmissionDialog: FC<Props> = ({ onCreate }) => {
setError(true);
Logger.error("Error creating submission", e);
});
};

const onSubmit: SubmitHandler<CreateSubmissionInput> = (data) => {
createSubmission(data);
const onSubmit: SubmitHandler<CreateSubmissionInput> = async (data) => {
await createSubmission(data);
};

const validateEmpty = (value: string): string | null =>
Expand Down Expand Up @@ -564,6 +563,7 @@ const CreateDataSubmissionDialog: FC<Props> = ({ onCreate }) => {
tabIndex={0}
id="createSubmissionDialogCreateButton"
form="create-submission-dialog-form"
disabled={isSubmitting}
>
Create
</StyledDialogButton>
Expand Down

0 comments on commit 32d0e73

Please sign in to comment.