-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Components: Make Toolbar accessible #17875
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.
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.
@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
Toolbar
transforming 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:
Toolbar
has been renamed toToolbarGroup
.Toolbar
needs anaccessibilityLabel
prop.Toolbar
requires that its buttons are rendered using@wordpress/components
.1. Current
Toolbar
has been renamed toToolbarGroup
The current
Toolbar
on master still works, but now it will emit a deprecation warning with a suggestion to useToolbarGroup
instead, which name better describes its semantics.ToolbarGroup
has the same implementation as the currentToolbar
on 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
Toolbar
needs anaccessibilityLabel
prop.To use the new
Toolbar
, it's necessary to pass anaccessibilityLabel
prop to the component. Other than that, the API remains the same:When using
Toolbar
withoutaccessibilityLabel
, the component will fallback toToolbarGroup
and emit a warning.3. New
Toolbar
requires that its buttons are rendered using@wordpress/components
.Like
Button
,IconButton
,ToolbarButton
etc.Ideally, only
ToolbarButton
would 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/components
for toolbar items will see a warning.Other stuff
How is this different from
NavigableToolbar
NavigableToolbar
finds 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
Toolbar
solves all these issues. Also, it registersButton
s 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/Toolbar
adds around3.9 kB
gzipped to the bundle. My plan is to address higher-level cases likeToolbar
,Popover
or whatever is more urgent first. I want to see how well Reakit fits into the current@wordpress/components
implementation 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
Toolbar
API as little as possible. But this should be improved.ToolbarButton
must be more flexible and work for more cases besides onlyIconButton
. So, next steps would be improvingToolbar
API. 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: