Skip to content

Commit

Permalink
fix(BreadcrumbItem): remove href check for children of type string (#…
Browse files Browse the repository at this point in the history
…9226)

Co-authored-by: Andrea N. Cardona <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Jul 30, 2021
1 parent dfeb4d4 commit 958da95
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions packages/react/src/components/Breadcrumb/Breadcrumb-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const breadcrumb = () => (
</BreadcrumbItem>
<BreadcrumbItem href="#">Breadcrumb 2</BreadcrumbItem>
<BreadcrumbItem href="#">Breadcrumb 3</BreadcrumbItem>
<BreadcrumbItem>Breadcrumb 4</BreadcrumbItem>
</Breadcrumb>
);

Expand All @@ -53,6 +54,7 @@ export const breadcrumbWithOverflowMenu = () => (
</OverflowMenu>
</BreadcrumbItem>
<BreadcrumbItem href="#">Breadcrumb 5</BreadcrumbItem>
<BreadcrumbItem>Breadcrumb 6</BreadcrumbItem>
</Breadcrumb>
);

Expand All @@ -74,5 +76,6 @@ export const playground = () => (
<BreadcrumbItem href="#" {...props()}>
Breadcrumb 3
</BreadcrumbItem>
<BreadcrumbItem>Breadcrumb 4</BreadcrumbItem>
</Breadcrumb>
);
12 changes: 8 additions & 4 deletions packages/react/src/components/Breadcrumb/BreadcrumbItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,16 @@ const BreadcrumbItem = React.forwardRef(function BreadcrumbItem(
);
}

if (typeof children === 'string' && href) {
if (typeof children === 'string') {
return (
<li className={className} ref={ref} {...rest}>
<Link href={href} aria-current={ariaCurrent}>
{children}
</Link>
{href ? (
<Link href={href} aria-current={ariaCurrent}>
{children}
</Link>
) : (
<span className={`${prefix}--link`}>{children}</span>
)}
</li>
);
}
Expand Down

0 comments on commit 958da95

Please sign in to comment.