Skip to content

Need global feedback on instance form validation error #2345

Closed

Description

@david-crespo

When you try to make an instance without selecting an image (for example) the form refuses to submit and there is an error on the image field, but if you're scrolled down past the image field, you don't see anything. The form just refuses to submit.

image

Activity

  1. added this to the 10 milestone on Jul 29, 2024
  2. changed the title [-]No global feedback on instance form validation error[/-] [+]Need global feedback on instance form validation error[/+] on Jul 29, 2024
  3. david-crespo commented on Aug 12, 2024

    @david-crespo
    CollaboratorAuthor

    While working on #2358 I noticed that our forms scroll to the error when there's a validation error. I think I was so used to that behavior that I hadn't consciously registered that it was happening. The good news is: other fields in this form have the correct scroll-to behavior. For example, if you go here and scroll down and hit submit without entering anything in the fields, it will scroll you to the name field because it's the first one with an error.

    https://console-h4730wth3-oxidecomputer.vercel.app/projects/mock-project/instances-new

    This behavior uses the ref on the field returned from useController to do the scrolling. I confirmed this by leaving ref out on NameField (technically TextFieldInner where it actually happens) and the scroll-to behavior stopped happening. So we just need fix the image field in particular, which should be a one-liner once we find the right line. Simply adding ref={field.ref} to the Listbox call here does not do it.

    const { field, fieldState } = useController({ name, control, rules: { required } })
    return (
    <div className={cn('max-w-lg', className)}>
    <Listbox
    description={description}

  4. self-assigned this
    on Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions