-
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
Improve block inserter keyboard navigation #26938
Conversation
Size Change: +373 B (0%) Total Size: 1.4 MB
ℹ️ View Unchanged
|
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.
I love this! Haven't tried it locally though, just some minor nitpicking.
packages/block-editor/src/components/block-types-list/style.scss
Outdated
Show resolved
Hide resolved
Tested on macOS with VoiceOver/Safari and Windows 10 with NVDA/Firefox. The keyboard-only interaction is great, it's much easier to get to a specific block. With the screen readers, things get a bit confusing: each section still has a role of If we implement this change, we should replace the |
I've tested the latest changes, here are my findings.
That's all for now, thanks. |
@alexstine Thanks a lot for the feedback.
That makes sense. Since this PR aims to improve the navigation while in the block list, I think we should address that in a follow-up PR.
Good catch! Fixed that.
I made another PR to discuss and address that (#28393).
The instructions are added through a I couldn't find a way to announce the instructions in between them, but I delayed the instructions a little bit so NVDA announces just like VoiceOver (category name, first block, and instructions), which I think also makes sense. |
NVDA still announces instructions, category name, and then the first item. If there's no way around this, I wouldn't call it a blocker by any means. Everything else seems to be working fine. Thanks. |
Hi, @tellthemachines, @gziolo, @kevin940726. 👋 Could you do another review on this? Also cc @talldan |
@diegohaz This is wonderful! I'm excited to see the My a11y knowledge is not as deep as some of the folks here. It's always a pleasure learning new things about this, especially through something like Reakit. I did interaction testing with both voiceover on and off. As others have noted, it's a great improvement! From a code perspective, I think the structure works very well. In the case of the 3-grid chunked layout of Inserter. Is there a difference between chunking items with Thanks <3 |
import InserterDraggableBlocks from '../inserter-draggable-blocks'; | ||
|
||
function InserterListItem( { | ||
className, | ||
composite, | ||
isFirst, |
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.
InserterListItem
isn't exposed as part of the public API so it's fine to change 👍🏻
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.
LGTM! Thanks for the walk through earlier, it was super helpful 🚀
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.
LGTM 👍 Thank you for working on this ❤️
@ItsJonQ Yes! The orientation will only enable/disable arrow keys, but pressing vertical arrow keys will still move to left/right. |
The problem
Currently, the block inserter (the one you open by clicking on the
Add block
button at the header toolbar) is visually represented as a two-dimensional grid. To reduce the number of tab stops, each category is implemented as a listbox, so keyboard and screen reader users can use arrow keys to move through the options.The problem is that, for sighted keyboard users — who can see that there are items above and below the currently focused one —, moving to the right, and not down, by pressing the down arrow key, can be problematic.
This solution
This PR implements two-dimensional keyboard navigation on the block inserter based on #24975 (comment) and #21080 (comment) (please, refer to these issues for more context on the implementation and alternatives).
How to test
Try the block inserter keyboard navigation (using arrow keys) on different browsers and screen readers.