Skip to content

Commit

Permalink
fix: Crash when editing column with only one defined min/max value (#897
Browse files Browse the repository at this point in the history
)

**Fix crash due to undefined min/max values causing toFixed error**

When editing a column with only one defined min or max value, the app
would crash with the error "cannot read properties of undefined (reading
'toFixed')".
To resolve this, we updated the validation logic to allow undefined
values for min and max. This prevents the app from attempting to format
undefined values, eliminating the crash and allowing users to safely
edit columns with incomplete min/max values.
  • Loading branch information
chavda-bhavik authored Dec 7, 2024
2 parents c1cd3e6 + 20b69da commit 0ffe98f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions apps/web/design-system/validation/MinMaxValidation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,33 +45,33 @@ 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 }) => (
<NumberInput
size={size}
min={min}
placeholder={minPlaceholder}
error={(errors?.validations?.[index] as any)?.min?.message}
value={field.value}
onChange={(value) => (value === '' ? field.onChange(undefined) : field.onChange(value))}
value={field.value ? field.value : undefined}
onChange={(value) => field.onChange(value === '' ? undefined : value)}
/>
)}
/>
<Controller
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 }) => (
<NumberInput
size={size}
max={max}
placeholder={maxPlaceholder}
error={(errors?.validations?.[index] as any)?.max?.message}
value={field.value}
onChange={(value) => (value === '' ? field.onChange(undefined) : field.onChange(value))}
value={field.value ? field.value : undefined}
onChange={(value) => field.onChange(value === '' ? undefined : value)}
/>
)}
/>
Expand Down

0 comments on commit 0ffe98f

Please sign in to comment.