Skip to content

Commit

Permalink
Add aria-current="page" to active navigation item (#36946)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin940726 committed Nov 30, 2021
1 parent 81015b0 commit 201ee37
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/components/src/navigation/item/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ export default function NavigationItem( props ) {
return null;
}

const isActive = item && activeItem === item;

const classes = classnames( className, {
'is-active': item && activeItem === item,
'is-active': isActive,
} );

const onItemClick = ( event ) => {
Expand All @@ -67,7 +69,13 @@ export default function NavigationItem( props ) {
const baseProps = children ? props : { ...props, onClick: undefined };
const itemProps = isText
? restProps
: { as: Button, href, onClick: onItemClick, ...restProps };
: {
as: Button,
href,
onClick: onItemClick,
'aria-current': isActive ? 'page' : undefined,
...restProps,
};

return (
<NavigationItemBase { ...baseProps } className={ classes }>
Expand Down

0 comments on commit 201ee37

Please sign in to comment.