Skip to content

Commit

Permalink
add accessibility props to target
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoskolodny committed Oct 3, 2023
1 parent a9890f2 commit e7efbbd
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,13 @@ export const Menu: React.FC<MenuProps> = ({
};
});

React.useEffect(() => {
if (target) {
target.setAttribute('role', 'menu');
target.setAttribute('aria-expanded', String(isMenuOpen));
}
}, [target, isMenuOpen]);

return (
<div {...getPrefixedDataAttributes(dataAttributes, 'Menu')}>
{renderTarget({...targetProps, isMenuOpen})}
Expand Down

0 comments on commit e7efbbd

Please sign in to comment.