Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

instance create: focus image field on validation error #2364

Merged
merged 4 commits into from
Aug 13, 2024

Conversation

david-crespo
Copy link
Collaborator

@david-crespo david-crespo commented Aug 12, 2024

Closes #2345

RHF automatically focuses the first field with an error, but we were not passing the ref for the image select listbox through to the button. And it must be the button specifically because the wrapping divs are not focusable unless they have a tabindex.

2024-08-12-focus-image-field.mp4

Copy link

vercel bot commented Aug 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
console ✅ Ready (Inspect) Visit Preview Aug 12, 2024 7:10pm

@david-crespo
Copy link
Collaborator Author

david-crespo commented Aug 12, 2024

WHAT ARE YOU EVEN TALKING ABOUT

image

Can't repro locally. Maybe this is that thing where GH actions randomly pull in data from another branch?

image

@david-crespo
Copy link
Collaborator Author

david-crespo commented Aug 12, 2024

Ok, whew. I was able to repro locally after rm -rf node_modules. It has to do with not being able to do generics with forwardRef in a nice way.

(noticed while checking existing Listbox references)
@@ -79,6 +79,7 @@ export function ListboxField<
name={name}
hasError={fieldState.error !== undefined}
isLoading={isLoading}
buttonRef={field.ref}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Something I noticed while looking at this is that even after adding ref, we are not giving all the props from field to Listbox. We are still missing onBlur and disabled, both of which could become more UX-relevant in the future. For example, if we change a form from the RHF default of validating on submit to validating on blur, the lack of onBlur here will be a problem. Similarly, if we do #1895, I think the lack of disabled here will be a problem. We can fix it here, but I'm guessing there are a bunch more cases like this.

@david-crespo david-crespo merged commit 3a6f815 into main Aug 13, 2024
8 checks passed
@david-crespo david-crespo deleted the fix-missing-image-focus branch August 13, 2024 16:20
david-crespo added a commit to oxidecomputer/omicron that referenced this pull request Aug 14, 2024
oxidecomputer/console@17ae890...29398e7

* [29398e74](oxidecomputer/console@29398e74) oxidecomputer/console#2343
* [68e2dc89](oxidecomputer/console@68e2dc89) oxidecomputer/console#2359
* [11e29ed8](oxidecomputer/console@11e29ed8) bump omicron to latest main
* [b6ed3757](oxidecomputer/console@b6ed3757) oxidecomputer/console#2370
* [af6c1f4a](oxidecomputer/console@af6c1f4a) oxidecomputer/console#2368
* [60ef745c](oxidecomputer/console@60ef745c) disallow unreachable code in ts config, fix one case of it
* [3a6f815a](oxidecomputer/console@3a6f815a) oxidecomputer/console#2364
* [80b3f2f3](oxidecomputer/console@80b3f2f3) oxidecomputer/console#2366
* [dab60d9d](oxidecomputer/console@dab60d9d) oxidecomputer/console#2358
* [8e3314f1](oxidecomputer/console@8e3314f1) oxidecomputer/console#2362
* [9b5cdfa0](oxidecomputer/console@9b5cdfa0) bump TS generator for bugfix (just adds whitespace)
* [07b6c151](oxidecomputer/console@07b6c151) oxidecomputer/console#2349
* [d32fddc2](oxidecomputer/console@d32fddc2) Revert "Focus confirm button instead of cancel in modals (oxidecomputer/console#2340)"
* [84a1501e](oxidecomputer/console@84a1501e) oxidecomputer/console#2341
* [6615cb6b](oxidecomputer/console@6615cb6b) oxidecomputer/console#2340
* [e48b0096](oxidecomputer/console@e48b0096) delete unused vscode tasks
* [22a6c50f](oxidecomputer/console@22a6c50f) tighten TypeValueCell spacing
* [4eacb3d7](oxidecomputer/console@4eacb3d7) oxidecomputer/console#2338
* [f278a747](oxidecomputer/console@f278a747) oxidecomputer/console#2332
* [016ad1b4](oxidecomputer/console@016ad1b4) oxidecomputer/console#2337
* [2d1a22a2](oxidecomputer/console@2d1a22a2) oxidecomputer/console#2336
* [be0f087f](oxidecomputer/console@be0f087f) oxidecomputer/console#2329
david-crespo added a commit to oxidecomputer/omicron that referenced this pull request Aug 16, 2024
oxidecomputer/console@17ae890...33b7a50

* [33b7a505](oxidecomputer/console@33b7a505) oxidecomputer/console#2360
* [1a2cb52d](oxidecomputer/console@1a2cb52d) oxidecomputer/console#2369
* [9e831174](oxidecomputer/console@9e831174) oxidecomputer/console#2374
* [e30f2eb8](oxidecomputer/console@e30f2eb8) oxidecomputer/console#2373
* [bb53f1b2](oxidecomputer/console@bb53f1b2) oxidecomputer/console#2371
* [29398e74](oxidecomputer/console@29398e74) oxidecomputer/console#2343
* [68e2dc89](oxidecomputer/console@68e2dc89) oxidecomputer/console#2359
* [11e29ed8](oxidecomputer/console@11e29ed8) bump omicron to latest main
* [b6ed3757](oxidecomputer/console@b6ed3757) oxidecomputer/console#2370
* [af6c1f4a](oxidecomputer/console@af6c1f4a) oxidecomputer/console#2368
* [60ef745c](oxidecomputer/console@60ef745c) disallow unreachable code in ts config, fix one case of it
* [3a6f815a](oxidecomputer/console@3a6f815a) oxidecomputer/console#2364
* [80b3f2f3](oxidecomputer/console@80b3f2f3) oxidecomputer/console#2366
* [dab60d9d](oxidecomputer/console@dab60d9d) oxidecomputer/console#2358
* [8e3314f1](oxidecomputer/console@8e3314f1) oxidecomputer/console#2362
* [9b5cdfa0](oxidecomputer/console@9b5cdfa0) bump TS generator for bugfix (just adds whitespace)
* [07b6c151](oxidecomputer/console@07b6c151) oxidecomputer/console#2349
* [d32fddc2](oxidecomputer/console@d32fddc2) Revert "Focus confirm button instead of cancel in modals (oxidecomputer/console#2340)"
* [84a1501e](oxidecomputer/console@84a1501e) oxidecomputer/console#2341
* [6615cb6b](oxidecomputer/console@6615cb6b) oxidecomputer/console#2340
* [e48b0096](oxidecomputer/console@e48b0096) delete unused vscode tasks
* [22a6c50f](oxidecomputer/console@22a6c50f) tighten TypeValueCell spacing
* [4eacb3d7](oxidecomputer/console@4eacb3d7) oxidecomputer/console#2338
* [f278a747](oxidecomputer/console@f278a747) oxidecomputer/console#2332
* [016ad1b4](oxidecomputer/console@016ad1b4) oxidecomputer/console#2337
* [2d1a22a2](oxidecomputer/console@2d1a22a2) oxidecomputer/console#2336
* [be0f087f](oxidecomputer/console@be0f087f) oxidecomputer/console#2329
david-crespo added a commit to oxidecomputer/omicron that referenced this pull request Aug 16, 2024
#6366)

oxidecomputer/console@17ae890...33b7a50

* [33b7a505](oxidecomputer/console@33b7a505)
oxidecomputer/console#2360
* [1a2cb52d](oxidecomputer/console@1a2cb52d)
oxidecomputer/console#2369
* [9e831174](oxidecomputer/console@9e831174)
oxidecomputer/console#2374
* [e30f2eb8](oxidecomputer/console@e30f2eb8)
oxidecomputer/console#2373
* [bb53f1b2](oxidecomputer/console@bb53f1b2)
oxidecomputer/console#2371
* [29398e74](oxidecomputer/console@29398e74)
oxidecomputer/console#2343
* [68e2dc89](oxidecomputer/console@68e2dc89)
oxidecomputer/console#2359
* [11e29ed8](oxidecomputer/console@11e29ed8)
bump omicron to latest main
* [b6ed3757](oxidecomputer/console@b6ed3757)
oxidecomputer/console#2370
* [af6c1f4a](oxidecomputer/console@af6c1f4a)
oxidecomputer/console#2368
* [60ef745c](oxidecomputer/console@60ef745c)
disallow unreachable code in ts config, fix one case of it
* [3a6f815a](oxidecomputer/console@3a6f815a)
oxidecomputer/console#2364
* [80b3f2f3](oxidecomputer/console@80b3f2f3)
oxidecomputer/console#2366
* [dab60d9d](oxidecomputer/console@dab60d9d)
oxidecomputer/console#2358
* [8e3314f1](oxidecomputer/console@8e3314f1)
oxidecomputer/console#2362
* [9b5cdfa0](oxidecomputer/console@9b5cdfa0)
bump TS generator for bugfix (just adds whitespace)
* [07b6c151](oxidecomputer/console@07b6c151)
oxidecomputer/console#2349
* [d32fddc2](oxidecomputer/console@d32fddc2)
Revert "Focus confirm button instead of cancel in modals
(oxidecomputer/console#2340)"
* [84a1501e](oxidecomputer/console@84a1501e)
oxidecomputer/console#2341
* [6615cb6b](oxidecomputer/console@6615cb6b)
oxidecomputer/console#2340
* [e48b0096](oxidecomputer/console@e48b0096)
delete unused vscode tasks
* [22a6c50f](oxidecomputer/console@22a6c50f)
tighten TypeValueCell spacing
* [4eacb3d7](oxidecomputer/console@4eacb3d7)
oxidecomputer/console#2338
* [f278a747](oxidecomputer/console@f278a747)
oxidecomputer/console#2332
* [016ad1b4](oxidecomputer/console@016ad1b4)
oxidecomputer/console#2337
* [2d1a22a2](oxidecomputer/console@2d1a22a2)
oxidecomputer/console#2336
* [be0f087f](oxidecomputer/console@be0f087f)
oxidecomputer/console#2329
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.

Need global feedback on instance form validation error
2 participants