-
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
Fix issue with top bar menu having unique ARIA roles #13059
Conversation
WP Updates
WP Updates
WP Updates
WP Updates
WP Updates
WP Updates
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.
Hi @Firestorm980 thank you for your contribution. I don't notice any visual changes and it looks like things are working correctly.
Previously on the ellipsis menu, it was not possible to use the arrow down to navigate between all the menu items and now it is (which is an improvament).
cc: @afercia, @tofumatt would it be possible to have a look at this PR regarding the a11y point of view?
@@ -33,9 +37,14 @@ export function MenuGroup( { | |||
return ( | |||
<div className={ classNames }> | |||
{ label && | |||
<div className="components-menu-group__label" id={ labelId }>{ label }</div> | |||
<div | |||
className={ `components-menu-group__label ${ ( isScreenReaderLabel ) ? 'screen-reader-text' : '' }` } |
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.
Here if isScreenReaderLabel is false we add an unnecessary space. What if we use the classnames util e.g:
className={ classnames( 'components-menu-group__label', {
['screen-reader-text']: isScreenReaderLabel
} }
} | ||
<NavigableMenu orientation="vertical" aria-labelledby={ labelId }> | ||
<NavigableMenu orientation="vertical" aria-labelledby={ labelId } role={ role } useEventToOffset={ useEventToOffset }> |
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.
Seems to me the wrapper element (the one with role=menu) has now an aria-labelledby attribute that points to a non existing ID (while the groups are OK). It makes sense to use the visible titles for the groups but also the menu should be labelled.
In the W3C example, the menu uses an aria-label="Text Formatting"
. In the same way, this menu could use an aria-label when the role === menu.
@Firestorm980 thanks so much for working on this 🙂 I've left one minor comment (the whole menu should be labelled). Keyboard interaction is greatly improved 👍 |
@Firestorm980 - do you plan to address feedback left? It looks like it is very close to be ready to ship. We would like to include it in the plugin's release planned for the middle of February. Edit: It now has some conflicts with |
@gziolo I should be able to get to this one in the next couple days. |
WP Updates
This reverts commit c52db84.
@@ -19,6 +19,10 @@ export function MenuGroup( { | |||
className = '', | |||
instanceId, | |||
label, | |||
role = 'menu', | |||
labelRole = ( role === 'group' ) ? { role: 'presentation' } : {}, |
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'd remove this, as role=presentation is useful to "flatten" the accessibility tree but there's no need for it, as the div
it applies to is already ignored.
@Firestorm980 hello. Do you have time to address the pending issues? If not, please let us know. These changes would greatly improve keyboard interaction in the more menu. If you don't have time, we can always copy your branch to the main repo preserving commits and attributions, and proceed from there. Thanks! |
@afercia in case we don't hear back from @Firestorm980 soon, I opened #14525 whit all commits transferred. In addition, I rebased new PR with all the changes applied in |
Removed the "stale" label as it seems it no longer is :) |
Sorry about the delay in communication on this one. Hopefully will have another commit up soon with fixes. |
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.
See my comments. In general, this PR goes in the right direction but it would be nice to explore whether we should introduce new common component Menu
which represents the modified version of MenuGroup
. While those two are similar, they are conceptually different.
@@ -68,6 +68,11 @@ class NavigableContainer extends Component { | |||
const { getFocusableContext } = this; | |||
const { cycle = true, eventToOffset, onNavigate = noop, stopNavigationEvents } = this.props; |
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.
const { cycle = true, eventToOffset, onNavigate = noop, stopNavigationEvents } = this.props; | |
const { cycle = true, eventToOffset = noop, onNavigate = noop, stopNavigationEvents } = this.props; |
This should be enough to make this work instead of the check:
// This avoids a console error when eventToOffset is null
<PluginMoreMenuGroup.Slot fillProps={ { onClose } } /> | ||
<ToolsMoreMenuGroup.Slot fillProps={ { onClose } } /> | ||
<MenuGroup> | ||
<MenuGroup label={ menuLabel } isLabelHidden={ true }> |
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.
Fragment
is no longer necessary to wrap components.
@@ -19,6 +19,9 @@ export function MenuGroup( { | |||
className = '', | |||
instanceId, | |||
label, | |||
role = 'menu', |
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.
It feels wrong to see the default role set menu
for the component which is called MenuGroup
and then see it overridden back to group
in other places. It seems like we need to introduce another component called Menu
which will have role
set to menu
, its class name which will hide the label for the menu, and will always have useEventToOffset
set to true
. This will make it possible to leave MenuGroup
usage 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.
@gziolo should we spin up a new issue for 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.
I would feel comfortable doing it as part of this PR because in the current form you might see unexpected role="menu"
in all plugins using MenuGroup
.
Arriving here via #14843 and considering the recommendations from #12505, I wonder what it is that
The challenge is in how it's used today, the "More Options" menu doesn't implement any of these behaviors on the wrapping dropdown. It seems like something we'd expect out of the I would expect:
tl;dr We seem to be trying to let |
Thank you for your contribution so far, it helped us better understand what would be the best approach here. I'm personally leaning towards including the changes proposed here in #14843. It means there is going to be more aggressive refactoring required to make it work as @afercia described in #12505. However, it seems like we would be able to address all concerns shared in the original issue. In addition, this will give us more control over |
Description
Closes #12505. Adds role options to menus so that the items within the main more menu can now be groups within the menu. Should fix issues with keyboard navigation as well as roles. The menu options/props default to what they used to be, so if it isn't specified and these menus are used elsewhere, it should fallback to the old functionality.
How has this been tested?
test-e2e
within Gutenberg docker.Types of changes
group
instead ofmenu
and wraps within a parentmenu
Checklist: