Skip to content
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 12501 menu item aria label #12955

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions packages/components/src/menu-item/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import IconButton from '../icon-button';
*/
export function MenuItem( {
children,
label = children,
info,
className,
icon,
Expand All @@ -38,9 +37,6 @@ export function MenuItem( {
'has-icon': icon,
} );

// Avoid using label if it is passed as non-string children.
label = isString( label ) ? label : undefined;

if ( info ) {
const infoId = 'edit-post-feature-toggle__info-' + instanceId;

Expand Down Expand Up @@ -77,7 +73,6 @@ export function MenuItem( {
return createElement(
tagName,
{
'aria-label': label,
// 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,
role,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
exports[`MenuItem should match snapshot when all props provided 1`] = `
<IconButton
aria-checked={true}
aria-label="My item"
className="components-menu-item__button my-class has-icon"
icon="wordpress"
onClick={[Function]}
Expand All @@ -20,7 +19,6 @@ exports[`MenuItem should match snapshot when all props provided 1`] = `
exports[`MenuItem should match snapshot when info is provided 1`] = `
<Button
aria-describedby="edit-post-feature-toggle__info-1"
aria-label="My item"
className="components-menu-item__button"
role="menuitem"
>
Expand All @@ -43,7 +41,6 @@ exports[`MenuItem should match snapshot when info is provided 1`] = `

exports[`MenuItem should match snapshot when isSelected and role are optionally provided 1`] = `
<IconButton
aria-label="My item"
className="components-menu-item__button my-class has-icon"
icon="wordpress"
onClick={[Function]}
Expand All @@ -59,7 +56,6 @@ exports[`MenuItem should match snapshot when isSelected and role are optionally

exports[`MenuItem should match snapshot when only label provided 1`] = `
<Button
aria-label="My item"
className="components-menu-item__button"
role="menuitem"
>
Expand Down
1 change: 0 additions & 1 deletion packages/components/src/menu-item/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ describe( 'MenuItem', () => {
</MenuItem>
);

expect( wrapper.prop( 'aria-label' ) ).not.toBeUndefined();
expect( wrapper ).toMatchSnapshot();
} );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ exports[`PluginMoreMenuItem renders menu item as button properly 1`] = `
role="menu"
>
<button
aria-label="My plugin button menu item"
className="components-button components-icon-button components-menu-item__button has-icon has-text"
onClick={[Function]}
role="menuitem"
Expand Down