-
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
Fix aria-checked attribute not set for plugin settings buttons in Options dropdown #65667
Fix aria-checked attribute not set for plugin settings buttons in Options dropdown #65667
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
// Make sure aria-checked matches spec https://www.w3.org/TR/wai-aria-1.1/#aria-checked | ||
aria-checked={ | ||
props.role === 'menuitemcheckbox' || | ||
props.role === 'menuitemradio' | ||
? isSelected | ||
: undefined | ||
} |
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.
This is the same approach used in
gutenberg/packages/components/src/menu-item/index.tsx
Lines 60 to 65 in 8c5a0b6
// Make sure aria-checked matches spec https://www.w3.org/TR/wai-aria-1.1/#aria-checked | |
aria-checked={ | |
role === 'menuitemcheckbox' || role === 'menuitemradio' | |
? isSelected | |
: undefined | |
} |
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.
Since this component is more generic than MenuItem
, should we check for all of the roles are compatible with aria-checked
? Ie. checkbox
, option
, radio
, switch
, menuitemcheckbox
, menuitemradio
, treeitem
? (source)
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 think the component rendered by plugins will always be MenuItem
. See:
gutenberg/packages/interface/src/components/complementary-area-more-menu-item/index.js
Lines 13 to 50 in 69efbca
const PluginsMenuItem = ( { | |
// Menu item is marked with unstable prop for backward compatibility. | |
// They are removed so they don't leak to DOM elements. | |
// @see https://github.com/WordPress/gutenberg/issues/14457 | |
__unstableExplicitMenuItem, | |
__unstableTarget, | |
...restProps | |
} ) => <MenuItem { ...restProps } />; | |
export default function ComplementaryAreaMoreMenuItem( { | |
scope, | |
target, | |
__unstableExplicitMenuItem, | |
...props | |
} ) { | |
return ( | |
<ComplementaryAreaToggle | |
as={ ( toggleProps ) => { | |
return ( | |
<ActionItem | |
__unstableExplicitMenuItem={ | |
__unstableExplicitMenuItem | |
} | |
__unstableTarget={ `${ scope }/${ target }` } | |
as={ PluginsMenuItem } | |
name={ `${ scope }/plugin-more-menu` } | |
{ ...toggleProps } | |
/> | |
); | |
} } | |
role="menuitemcheckbox" | |
selectedIcon={ check } | |
name={ target } | |
scope={ scope } | |
{ ...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.
Updated. Thanks.
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 think the component rendered by plugins will always be
MenuItem
That's true, but <ComplementaryAreaToggle />
is a generic component that technically can be rendered as
anything, and therefore I don't think that checking for more roles can do any harm in this case
I wanted to add unit tests for that case but the component doesn't seem to have any tests at all. We can cover that case when we add tests to this component. |
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.
Makes sense. Thank you, @manzoorwanijk!
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 🚀
Hmm… the flow to cherry-pick this failed: https://github.com/WordPress/gutenberg/actions/runs/11232232902/job/31223400904 |
…ions dropdown (#65667) Co-authored-by: manzoorwanijk <manzoorwanijk@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org> Co-authored-by: ciampo <mciampini@git.wordpress.org>
…ions dropdown (#65667) Co-authored-by: manzoorwanijk <manzoorwanijk@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org> Co-authored-by: ciampo <mciampini@git.wordpress.org>
I just cherry-picked this PR to the wp/6.7 branch to get it included in the next release: 381ada5 |
What?
It fixes the a11y issue with plugin buttons in the options menu in the post editor where there is no indication of whether the plugin sidebar is already open or not.
Why?
Fixes #65666
How?
It updates
ComplementaryAreaToggle
to passaria-checked
if the role is set tomenuitemcheckbox
ormenuitemradio
Testing Instructions
aria-checked
attribute is set correctlyTesting Instructions for Keyboard
Screenshots or screencast