Skip to content

Commit

Permalink
Fixes #11431. Adjust aria-checked attribute to only work on matching …
Browse files Browse the repository at this point in the history
  • Loading branch information
BE-Webdesign committed Nov 3, 2018
1 parent 60e0b50 commit aed91c5
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions packages/components/src/menu-item/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,21 @@ export function MenuItem( {
props.icon = icon;
}

const atts = {
'aria-label': label,
role,
className,
...props,
};

// Make sure aria-checked matches spec https://www.w3.org/TR/wai-aria-1.1/#aria-checked
if ( role === 'menuitemcheckbox' || role === 'menuitemradio' ) {
atts[ 'aria-checked' ] = isSelected;
}

return createElement(
tagName,
{
'aria-label': label,
'aria-checked': isSelected,
role,
className,
...props,
},
atts,
children,
<Shortcut className="components-menu-item__shortcut" shortcut={ shortcut } />
);
Expand Down

0 comments on commit aed91c5

Please sign in to comment.