Skip to content
Merged
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
5 changes: 5 additions & 0 deletions .changeset/stupid-bats-end.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': patch
---

Stop rendering `activeClassName` when there is no `to` prop is passed for react-router (TabNav, SubNav, BreadCrumb, UnderlineNav v1)
2 changes: 1 addition & 1 deletion src/Breadcrumbs/Breadcrumbs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ type StyledBreadcrumbsItemProps = {
} & SxProp

const BreadcrumbsItem = styled.a.attrs<StyledBreadcrumbsItemProps>(props => ({
activeClassName: typeof props.to === 'string' ? 'selected' : '',
activeClassName: typeof props.to === 'string' ? 'selected' : undefined,
className: classnames(props.selected && SELECTED_CLASS, props.className),
'aria-current': props.selected ? 'page' : null,
}))<StyledBreadcrumbsItemProps>`
Expand Down
2 changes: 1 addition & 1 deletion src/SubNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ type StyledSubNavLinkProps = {
} & SxProp

const SubNavLink = styled.a.attrs<StyledSubNavLinkProps>(props => ({
activeClassName: typeof props.to === 'string' ? 'selected' : '',
activeClassName: typeof props.to === 'string' ? 'selected' : undefined,
className: classnames(ITEM_CLASS, props.selected && SELECTED_CLASS, props.className),
}))<StyledSubNavLinkProps>`
padding-left: ${get('space.3')};
Expand Down
2 changes: 1 addition & 1 deletion src/TabNav/TabNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export type TabNavLinkProps = React.DetailedHTMLProps<React.HTMLAttributes<HTMLA
} & SxProp

const TabNavLink = styled.a.attrs<TabNavLinkProps>(props => ({
activeClassName: typeof props.to === 'string' ? 'selected' : '',
activeClassName: typeof props.to === 'string' ? 'selected' : undefined,
className: classnames(ITEM_CLASS, props.selected && SELECTED_CLASS, props.className),
role: 'tab',
'aria-selected': !!props.selected,
Expand Down
2 changes: 1 addition & 1 deletion src/UnderlineNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ type StyledUnderlineNavLinkProps = {
} & SxProp

const UnderlineNavLink = styled.a.attrs<StyledUnderlineNavLinkProps>(props => ({
activeClassName: typeof props.to === 'string' ? 'selected' : '',
activeClassName: typeof props.to === 'string' ? 'selected' : undefined,
className: classnames(ITEM_CLASS, props.selected && SELECTED_CLASS, props.className),
}))<StyledUnderlineNavLinkProps>`
padding: ${get('space.3')} ${get('space.2')};
Expand Down