Skip to content

Don't validate on blur if field is not dirty #1289

Closed

Description

@david-crespo

This validation is a little aggro.

2022-11-07-aggro-validation

You shouldn't get screamed at if all you do is blur the field (e.g., to look at the rest of the form if the form is longer). My first thought is that we can simply not validate on blur until the field (or the form?) is empty. I kind of doubt we can implement this on the form itself using mode because the options are pretty flat — submit, blur, change, touched, all. However, it would be pretty do at the display layer: regardless of whether there is an error on the field, only show it under certain conditions, which we can pull from the field and form state.

render={({ field, fieldState: { error } }) => {
return (
<>
<UITextField
title={label}
type={type}
error={!!error}
aria-labelledby={cn(`${id}-label`, {
[`${id}-help-text`]: !!description,
})}
aria-describedby={description ? `${id}-label-tip` : undefined}
{...field}
{...props}
/>
<ErrorMessage error={error} label={label} />
</>
)
}}

Activity

  1. david-crespo commented on Feb 8, 2023

    @david-crespo
    CollaboratorAuthor

    To me this is pretty annoying in all the core flows in the app, but it's not broken per se, so I'm putting it at the top of MVP+1 for now.

  2. added this to the MVP+1 milestone on Feb 8, 2023
  3. david-crespo commented on Oct 4, 2023

    @david-crespo
    CollaboratorAuthor

    I'm not sure there's a nice way to fix this, so it might be prudent to decide we can live with it. I don't really like my display-level hiding idea — I think it's a recipe for pain to have validation errors that aren't displayed.

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

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions