Skip to content

Commit b71cb1f

Browse files
Stop rendering activeClassName when there is no to prop is passed for react-router (#3061)
* do not render the activeclassname when there is no prop 'to' * add changeset
1 parent 10408d8 commit b71cb1f

File tree

5 files changed

+9
-4
lines changed

5 files changed

+9
-4
lines changed

.changeset/stupid-bats-end.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@primer/react': patch
3+
---
4+
5+
Stop rendering `activeClassName` when there is no `to` prop is passed for react-router (TabNav, SubNav, BreadCrumb, UnderlineNav v1)

src/Breadcrumbs/Breadcrumbs.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ type StyledBreadcrumbsItemProps = {
5959
} & SxProp
6060

6161
const BreadcrumbsItem = styled.a.attrs<StyledBreadcrumbsItemProps>(props => ({
62-
activeClassName: typeof props.to === 'string' ? 'selected' : '',
62+
activeClassName: typeof props.to === 'string' ? 'selected' : undefined,
6363
className: classnames(props.selected && SELECTED_CLASS, props.className),
6464
'aria-current': props.selected ? 'page' : null,
6565
}))<StyledBreadcrumbsItemProps>`

src/SubNav.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ type StyledSubNavLinkProps = {
6363
} & SxProp
6464

6565
const SubNavLink = styled.a.attrs<StyledSubNavLinkProps>(props => ({
66-
activeClassName: typeof props.to === 'string' ? 'selected' : '',
66+
activeClassName: typeof props.to === 'string' ? 'selected' : undefined,
6767
className: classnames(ITEM_CLASS, props.selected && SELECTED_CLASS, props.className),
6868
}))<StyledSubNavLinkProps>`
6969
padding-left: ${get('space.3')};

src/TabNav/TabNav.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export type TabNavLinkProps = React.DetailedHTMLProps<React.HTMLAttributes<HTMLA
8181
} & SxProp
8282

8383
const TabNavLink = styled.a.attrs<TabNavLinkProps>(props => ({
84-
activeClassName: typeof props.to === 'string' ? 'selected' : '',
84+
activeClassName: typeof props.to === 'string' ? 'selected' : undefined,
8585
className: classnames(ITEM_CLASS, props.selected && SELECTED_CLASS, props.className),
8686
role: 'tab',
8787
'aria-selected': !!props.selected,

src/UnderlineNav.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ type StyledUnderlineNavLinkProps = {
7070
} & SxProp
7171

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

0 commit comments

Comments
 (0)