Skip to content

Commit

Permalink
fix: handle null when provided to text/textarea/number fields
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvxd committed Jan 18, 2025
1 parent 5c60d6a commit e778246
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ export const DefaultField = ({
field,
onChange,
readOnly,
value,
value: _value,
name,
label,
Label,
id,
}: FieldPropsInternal) => {
const value = _value as string | number | undefined | null;

return (
<Label
label={label || name}
Expand All @@ -32,7 +34,7 @@ export const DefaultField = ({
type={field.type}
title={label || name}
name={name}
value={typeof value === "undefined" ? "" : value.toString()}
value={value?.toString ? value.toString() : ""}
onChange={(e) => {
if (field.type === "number") {
const numberValue = Number(e.currentTarget.value);
Expand Down

0 comments on commit e778246

Please sign in to comment.