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

aria-current in NavLink #4707 #4708

Merged
merged 1 commit into from
Jul 5, 2017
Merged
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
8 changes: 6 additions & 2 deletions packages/react-router-dom/modules/NavLink.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const NavLink = ({
activeStyle,
style,
isActive: getIsActive,
ariaCurrent,
...rest
}) => (
<Route
Expand All @@ -28,6 +29,7 @@ const NavLink = ({
to={to}
className={isActive ? [ activeClassName, className ].join(' ') : className}
style={isActive ? { ...style, ...activeStyle } : style}
aria-current={isActive && ariaCurrent}
{...rest}
/>
)
Expand All @@ -43,11 +45,13 @@ NavLink.propTypes = {
className: PropTypes.string,
activeStyle: PropTypes.object,
style: PropTypes.object,
isActive: PropTypes.func
isActive: PropTypes.func,
ariaCurrent: PropTypes.oneOf(['page', 'step', 'location', 'true'])
}

NavLink.defaultProps = {
activeClassName: 'active'
activeClassName: 'active',
ariaCurrent: 'true'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be page by default? That seems to be the most common use case within a routing library.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggested true because it's the least specific (and therefore the most widely applicable) value, but you could be right. My thought was that in some cases, it's not a page that's active like in the case of a nested route (think an onboarding flow that might have multiple steps in one similar view, ergo step).

Totally open to some more informed opinions of course, I'm just speculating.

}

export default NavLink