From 20b69daf627704e5adcabdff0ff4f1ae0293a065 Mon Sep 17 00:00:00 2001 From: Mayur Date: Sat, 7 Dec 2024 14:01:37 +0530 Subject: [PATCH] fix: Crash when editing column with only one defined min/max value --- .../design-system/validation/MinMaxValidation.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/web/design-system/validation/MinMaxValidation.tsx b/apps/web/design-system/validation/MinMaxValidation.tsx index 4c3bbab7..28f47684 100644 --- a/apps/web/design-system/validation/MinMaxValidation.tsx +++ b/apps/web/design-system/validation/MinMaxValidation.tsx @@ -45,7 +45,7 @@ export function MinMaxValidation({ control={control} name={`validations.${index}.min`} rules={{ - validate: (value, formValues) => validateMinMax(value, (formValues.validations?.[index] as any).max), + validate: (value, formValues) => validateMinMax(value, (formValues.validations?.[index] as any)?.max), }} render={({ field }) => ( (value === '' ? field.onChange(undefined) : field.onChange(value))} + value={field.value ? field.value : undefined} + onChange={(value) => field.onChange(value === '' ? undefined : value)} /> )} /> @@ -62,7 +62,7 @@ export function MinMaxValidation({ control={control} name={`validations.${index}.max`} rules={{ - validate: (value, formValues) => validateMinMax((formValues.validations?.[index] as any).min, value), + validate: (value, formValues) => validateMinMax((formValues.validations?.[index] as any)?.min, value), }} render={({ field }) => ( (value === '' ? field.onChange(undefined) : field.onChange(value))} + value={field.value ? field.value : undefined} + onChange={(value) => field.onChange(value === '' ? undefined : value)} /> )} />