Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/lib/core/components/Form/Controller/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ export const getFieldInitials = <
}

if (isNil(value)) {
if (spec.defaultValue) {
if (!(isNil(spec.defaultValue) || spec.defaultValue === '')) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In what cases do you add a check for an empty string?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to minimally change current behavior. And, as it seems to me, in most cases it's empty string = undefined.

value = transformArrIn(spec.defaultValue) as DirtyValue;
}
// if the spec with type array or object, and this spec has "required === true",
Expand Down Expand Up @@ -298,7 +298,7 @@ export const getFieldMethods = <
let value = transformArrIn(_value);

if (isNumberSpec(spec) && !error) {
value = (value ? Number(value) : undefined) as DirtyValue;
value = (isNil(value) || value === '' ? undefined : Number(value)) as DirtyValue;
}

let newChildErrors: Record<string, ValidateError> = {...state.childErrors};
Expand Down