-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Writing flow: Fix focus trap on certain input types #41538
Conversation
Size Change: +409 B (0%) Total Size: 1.24 MB
ℹ️ View Unchanged
|
@mirka Possible for you to add one E2E test showing this behavior? It would be nice so I can follow the instructions in the test on how to recreate the steps here. It seems like some blocks currently do not have this problem such as the image block. Once you focus it, you can move between the buttons with Left/Right Arrow keys I believe. Unrelated to this PR, if you are brave enough to touch the writing flow code, any of this look interesting? I have a lot of good ideas on how to improve A11Y but some of them are above my current React abilities. Thanks! |
Here's a branch (
Does that work? I thought a testing branch would be easier than reading an E2E, but let me know if that's not the case 😄
Correct, that's because the buttons in the Image block are |
They're certainly interesting and worthwhile to me, but I have a bit too much on my plate right now to take on a new focus area 😭 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mirka The PR looks good to me and does exactly what you say it should do. I tried to find any accessibility issues and could not.
I think it may be best to get at least one more sign off on this code considering how easy it is to break writing flow. I'd hate to have missed something which would come back to haunt us in the future.
This is fine with me. Note that generally editor UI (so most input elements in a block) should go in a placeholder, which will in the future be outside of the writing flow logic. Only input that are previews (and thus editable) should go inside blocks without wrapping it in a placeholder. |
Thanks for the reviews everyone!
That makes sense. It's probably a relatively rare use case, hence not being a problem for the vast majority. |
Fixes #32715
What?
Fixes an issue where keyboard focus could get stuck on certain types of
<input>
elements when using the left/right arrow keys to navigate interactive elements within a block.Why?
There is no need to prevent horizontal arrow nav on
input
element types that do not require horizontal arrow nav internally, such ascheckbox
andradio
.How?
I picked out an allowlist of input types (from MDN) that are safe to be navigation candidates.
Testing Instructions
Add a
<input type="checkbox" />
to the edit component of a core block, such asCode
. If necessary, flexbox the container so the buttons are horizontally aligned.Example modification of the Code block:
Move keyboard focus to the first
<input>
, and hit the right arrow key.Screenshots or screencast
CleanShot.2022-06-03.at.23.01.11.mp4