Skip to content

ArrayField - UX issue in validation error handling when only one Field has a validation error #285

Description

@corovcam

I would like to ask what is the reason behind the hasGroupErrors method in ArrayField:

hasGroupErrors = (errors) => {
const { fieldPath } = this.props;
for (const field in errors) {
if (field.startsWith(fieldPath)) {
return true;
}
}
return false;
};

const hasError = this.hasGroupErrors(errors) ? { error: {} } : {};
const { nextKey } = this.state;
const valuesToDisplay = this.getValues(values, fieldPath);
return (
<Form.Field {...uiProps} {...hasError}>

What I don't understand is why there is an error object hasError that gets propagated down to SUI's Form.Field component. The UX problem I'm encountering here is if there is only one error in any field of the ArrayField, the whole ArrayField turns red (since empty error object in hasError is truthy in SUI's Form.Field props), and not just the specific Field with an error I would expect to be highlighted as red/error-y.

Image

I would expect this outcome:

Image

Also, related to this empty error object, there's React warning in the console:

Image

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions