Components: Make Toolbar accessible#17875
Components: Make Toolbar accessible#17875diegohaz wants to merge 86 commits intoWordPress:masterfrom
Conversation
This should be done upstream
packages/components/src/toolbar-button/accessible-toolbar-button.js
Outdated
Show resolved
Hide resolved
Nevermind, looks like it's on master indeed. Trying to find the commit that changed this. Found it: #17877 (comment) |
Marked the comments that were addressed as Future tasks I can think of:
|
This is a followup to a regression found in #17875, specifically #17877 (comment). The PR refactored horizontal margins, including for full-wide blocks. As a result, full-wide blocks would, on the mboile breakpoint, receive too much negative margin. This PR addresses that.
ItsJonQ
left a comment
There was a problem hiding this comment.
@diegohaz Amazing job with this PR!
I tested this locally in Gutenberg with keyboard + voiceover. It works as expected. There were a couple of hiccups, but those interactions already exist in Gutenberg today (unfortunately. We'll make it better!).
Based on the convo with @gziolo , I think a great fast follow PR would be to improve the SlotFIll related forceUpdate work around.
Thank you so much for all of your hard work.
Double thank you for your efforts and advocacy for Reakit and a11y!
Very excited to see how we can systematically improve the experience of Gutenberg as we start refactoring with Reakit within the components.
❤️
|
It's not clear to me yet how this impacts our existing public APIs and what's the potential of breakage of existing usage. Anyone able to write a summary? |
|
@youknowriad I wrote a summary here: #17875 (comment) It shouldn't break the current usage unless they're doing things within |
|
To be completely honest, I don't feel confident merging this PR as is. My concerns are: 1- Maybe it's just me but I find it too big, so hard to understand. I wonder if we can split it to increase confidence in the changes we're making.
This statement is a little bit unprecise to me. We can expect that plugin authors do all kind of weird things and Backwards compatibility is really important for WordPress, we can't break existing APIs. Some exceptions are possible when we know exactly what we're breaking, how we're breaking it and if the breakage is small enough. In that case, we can write a dev note for plugin authors to let them know how they should update their code to avoid breakage. |
|
@youknowriad In the meanwhile, other projects using My statement is so just because I don't have enough experience with how people create custom blocks, but maybe @gziolo may have a better perception. |
If we make it experimental, when do you think we could get out of the experimental phase? What concerns me the most is not the deprecations. Deprecations are good because they let developpers know what they should do. It seems like you're saying that we can add the new components without touching the existing Core blocks. That is reassuring. So aside deprecations which can potentially break e2e tests, if I'm a block author and I don't touch my code, is there something that can break? |
How is the process that is currently used to take things out of the experimental phase? The removal of the deprecation would allow us to change between both implementations and even revert this one entirely if it doesn't work out. One thing that I learned while working on this PR is that making things Steps I would propose (they could be separate PRs):
|
|
An iterative process like that sounds good to me 👍 |
|
Closing in favor of #18534 |
This is a followup to a regression found in #17875, specifically #17877 (comment). The PR refactored horizontal margins, including for full-wide blocks. As a result, full-wide blocks would, on the mboile breakpoint, receive too much negative margin. This PR addresses that.
This is a followup to a regression found in #17875, specifically #17877 (comment). The PR refactored horizontal margins, including for full-wide blocks. As a result, full-wide blocks would, on the mboile breakpoint, receive too much negative margin. This PR addresses that.
This is a followup to a regression found in #17875, specifically #17877 (comment). The PR refactored horizontal margins, including for full-wide blocks. As a result, full-wide blocks would, on the mboile breakpoint, receive too much negative margin. This PR addresses that.
Description
Fixes #15331.
Fixes #3383.
Related to #16514.
This PR fixes
Toolbartransforming it into an actual toolbar, addressing the accessibility concerns discussed on #15331, and leveraging the design discussions on #16514.I tried to touch the API as little as possible. But we have a few changes, all backward compatible:
Toolbarhas been renamed toToolbarGroup.Toolbarneeds anaccessibilityLabelprop.Toolbarrequires that its buttons are rendered using@wordpress/components.1. Current
Toolbarhas been renamed toToolbarGroupThe current
Toolbaron master still works, but now it will emit a deprecation warning with a suggestion to useToolbarGroupinstead, which name better describes its semantics.ToolbarGrouphas the same implementation as the currentToolbaron master. In fact, most of the code was copied and pasted to the new location.Just like today,
<ToolbarGroup isCollapsed />only acceptscontrols, notchildren.2. New
Toolbarneeds anaccessibilityLabelprop.To use the new
Toolbar, it's necessary to pass anaccessibilityLabelprop to the component. Other than that, the API remains the same:When using
ToolbarwithoutaccessibilityLabel, the component will fallback toToolbarGroupand emit a warning.3. New
Toolbarrequires that its buttons are rendered using@wordpress/components.Like
Button,IconButton,ToolbarButtonetc.Ideally, only
ToolbarButtonwould be accepted, and it would be flexible enough to render all kinds of toolbar items. Unfortunately, that's not the case forToolbarButton, and even Gutenberg uses different components as toolbar items to achieve different results.This means that block authors that aren't using
@wordpress/componentsfor toolbar items will see a warning.Other stuff
How is this different from
NavigableToolbarNavigableToolbarfinds all the tabbable elements within the toolbar whenever the user presses left and arrow keys. It determines which one is active and focuses the previous/next one. To conform with the WAI-ARIA recommendations, it still needs to:tabIndex="-1"on inactive items so the toolbar has only one tab stop.The new
Toolbarsolves all these issues. Also, it registersButtons when they're mounted and unregisters them when they're unmounted. Because of that, it doesn't need to run a query on the DOM every time an arrow key is pressed, which leads to a better performance.Reakit
This PR introduces a new dependency: Reakit. It's an open source library that provides low level components and hooks to address common accessibility aspects of design systems. It has 1000s of lines of tests to make sure accessible behaviors work. It's being used by projects like CodeSandbox and Gatsby. And is used here to add the roving tabindex method to
Toolbar.reakit/Toolbaradds around3.9 kBgzipped to the bundle. My plan is to address higher-level cases likeToolbar,Popoveror whatever is more urgent first. I want to see how well Reakit fits into the current@wordpress/componentsimplementation while trying to touch the components' API as little as possible.Once we have a few high-level components working with proper accessibility and less dependent of
@wordpress/components' abstractions, we can go deeper and determine what to do with things likeNavigableContainer.I think that's the path that will give us more flexibility to change things (even removing Reakit later, if needed) at the same time we provide more accessible ready-to-use components faster.
Next steps
As I said, I tried to touch the
ToolbarAPI as little as possible. But this should be improved.ToolbarButtonmust be more flexible and work for more cases besides onlyIconButton. So, next steps would be improvingToolbarAPI. Some discussions are happening on #16514.How has this been tested?
Checked the header toolbar and the block toolbar of many (if not all) blocks. Many end-to-end tests failed on the first iterations, so I went through each of them and fixed the issues.
Screenshots
Storybook
Playground
Types of changes
New feature
Checklist: