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

fix(hotfix/5.135.6): Use aria-current for active nav links #33390

Open
wants to merge 2 commits into
base: hotfix/5.135.6
Choose a base branch
from
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,12 @@ export class NavBase extends BaseComponent<INavProps, INavState> implements INav
theme,
onRenderLink = this._onRenderLink
} = this.props;
const isSelectedLink = this._isLinkSelected(link);
const { ariaCurrent = 'page' } = link;

const classNames = getClassNames(getStyles!, {
theme: theme!,
isSelected: this._isLinkSelected(link),
isSelected: isSelectedLink,
isButtonEntry: link.onClick && !link.forceAnchor,
leftPadding: _indentationSize * nestingLevel + _baseIndent,
groups
Expand All @@ -167,6 +169,7 @@ export class NavBase extends BaseComponent<INavProps, INavState> implements INav
title={ link.title || link.name }
target={ link.target }
rel={ rel }
aria-current={ isSelectedLink ? ariaCurrent : undefined }
aria-label={ link.ariaLabel }
>
{ onRenderLink(link, this._onRenderLink) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,11 @@ export interface INavLink {
*/
isExpanded?: boolean;

/**
* Aria-current token for active nav links. Must be a valid token value, and defaults to 'page'.
*/
ariaCurrent?: 'page' | 'step' | 'location' | 'date' | 'time' | 'true';

/**
* Aria label for nav link
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ exports[`Nav renders Nav correctly 1`] = `
name=""
>
<button
aria-current={undefined}
aria-describedby={null}
aria-label={undefined}
aria-labelledby={null}
Expand Down