From 7845476af1245b5113861ff3669fc10cc4678a6d Mon Sep 17 00:00:00 2001 From: Robert Azizbekyan <103438454+rAzizbekyan@users.noreply.github.com> Date: Mon, 18 Jul 2022 17:08:32 +0400 Subject: [PATCH] =?UTF-8?q?fixing=20forms=20not=20no=20be=20able=20to=20su?= =?UTF-8?q?bmit=20until=20all=20required=20fields=20are=20f=E2=80=A6=20(#2?= =?UTF-8?q?221)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fixing forms not no be able to submit until all required fields are filled * fixing topic form validation issue --- .../src/components/Schemas/New/New.tsx | 12 ++++++------ .../Topics/New/__test__/New.spec.tsx | 18 +++++++++++++++--- .../src/components/Topics/Topic/Edit/Edit.tsx | 1 + .../Topics/Topic/Edit/__test__/Edit.spec.tsx | 6 +++++- .../Topics/shared/Form/TopicForm.tsx | 15 ++++++++++----- .../shared/Form/__tests__/TopicForm.spec.tsx | 12 ++++++++++-- kafka-ui-react-app/src/lib/yupExtended.ts | 2 +- .../src/redux/interfaces/topic.ts | 4 ++-- .../reducers/topics/__test__/reducer.spec.ts | 4 ++-- .../src/redux/reducers/topics/topicsSlice.ts | 8 ++++---- 10 files changed, 56 insertions(+), 26 deletions(-) diff --git a/kafka-ui-react-app/src/components/Schemas/New/New.tsx b/kafka-ui-react-app/src/components/Schemas/New/New.tsx index 0d9d171b1f..1aa843d6b5 100644 --- a/kafka-ui-react-app/src/components/Schemas/New/New.tsx +++ b/kafka-ui-react-app/src/components/Schemas/New/New.tsx @@ -32,12 +32,12 @@ const New: React.FC = () => { const { clusterName } = useAppParams(); const navigate = useNavigate(); const dispatch = useAppDispatch(); - const methods = useForm(); + const methods = useForm({ mode: 'onChange' }); const { register, handleSubmit, control, - formState: { isDirty, isSubmitting, errors }, + formState: { isDirty, isSubmitting, errors, isValid }, } = methods; const onSubmit = async ({ @@ -99,15 +99,15 @@ const New: React.FC = () => {
Schema Type * ( + render={({ field: { name, onChange, value } }) => (