Skip to content

fix(sdk): TextArea is highlighted; empty required strings trigger an error#70

Open
szymon-t-sc wants to merge 1 commit into
mainfrom
bugfix/string-inputs
Open

fix(sdk): TextArea is highlighted; empty required strings trigger an error#70
szymon-t-sc wants to merge 1 commit into
mainfrom
bugfix/string-inputs

Conversation

@szymon-t-sc

Copy link
Copy Markdown
Member

No description provided.

onChange={onChange}
onBlur={onBlur}
size="medium"
error={errors.length > 0}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Before:
Image

After:
Image

if (trimmed === '') {
// eslint-disable-next-line unicorn/no-useless-undefined
handleChange(path, undefined);
} else if (isNumberInput) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

'' is saved as regular string.

We set undefined earlier to remove that property, allowing the validator to mark the field as required. This behavior was not implemented in TextArea, where '' was set instead, so the required validation error was not triggered.

This change unifies the behavior between the two fields.

Why use this approach instead of adding undefined to textarea? This is primarily a validator issue and should be fixed there. Removing the property works for new props, but if we set defaultProperties with empty '' (which is fine) validation will not work correctly because it assigns undefined onBlur in the control.

Having clear default values like '', which match the expected type, is preferable to relying on control behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant