From b7fc472f3503ae2eaf0e8a6d65c526d779bf6ef9 Mon Sep 17 00:00:00 2001 From: Ben Furber Date: Tue, 4 Jun 2024 16:19:38 +0100 Subject: [PATCH 1/2] fix: question form submitting not instantly set --- src/pages/Question/Content/Common/QuestionForm.tsx | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/pages/Question/Content/Common/QuestionForm.tsx b/src/pages/Question/Content/Common/QuestionForm.tsx index c584533fd6..6bdcb3a083 100644 --- a/src/pages/Question/Content/Common/QuestionForm.tsx +++ b/src/pages/Question/Content/Common/QuestionForm.tsx @@ -60,7 +60,7 @@ export const QuestionForm = (props: IProps) => { onSubmit={onSubmit} mutators={{ setAllowDraftSaveFalse }} initialValues={formValues} - render={({ submitting, handleSubmit, form, values }) => { + render={({ submitting, handleSubmit, pristine, valid, values }) => { const numberOfImageInputsAvailable = values?.images ? Math.min(values.images.length + 1, QUESTION_MAX_IMAGES) : 1 @@ -131,11 +131,8 @@ export const QuestionForm = (props: IProps) => { mt={3} variant="primary" type="submit" - disabled={submitting} - onClick={(event) => { - form.mutators.setAllowDraftSaveFalse() - handleSubmit(event) - }} + disabled={submitting || pristine || !valid} + onClick={handleSubmit} sx={{ width: '100%', mb: ['40px', '40px', 0], From 57902a905adbff8e32be3987b77090f38d193735 Mon Sep 17 00:00:00 2001 From: Ben Furber Date: Wed, 5 Jun 2024 09:54:09 +0100 Subject: [PATCH 2/2] fix: wrong question store logic on slug check --- src/stores/Question/question.store.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stores/Question/question.store.tsx b/src/stores/Question/question.store.tsx index 205f15b301..e82f1d995c 100644 --- a/src/stores/Question/question.store.tsx +++ b/src/stores/Question/question.store.tsx @@ -83,7 +83,7 @@ export class QuestionStore extends ModuleStore { .collection(COLLECTION_NAME) .doc(values?._id) - const isTitleAlreadyInUse = await !this.isTitleThatReusesSlug( + const isTitleAlreadyInUse = await this.isTitleThatReusesSlug( values.title, values?._id, )