Skip to content

Commit

Permalink
Fix/issue 12501 menu item aria label
Browse files Browse the repository at this point in the history
Removed aria-label on the menuItem component because it was redundant with the button text itself. Also update the tests and snapshots to match the new output.
  • Loading branch information
timwright12 authored and jorgefilipecosta committed Feb 1, 2019
1 parent 5134fcf commit 2b7085a
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 11 deletions.
5 changes: 0 additions & 5 deletions packages/components/src/menu-item/index.js
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
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
Expand Up @@ -61,7 +61,6 @@ describe( 'MenuItem', () => {
</MenuItem>
);

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

Expand Down
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

0 comments on commit 2b7085a

Please sign in to comment.