Skip to content

Commit

Permalink
#241 Fix bug when Breadcrumbs icon is rendered between non-rendered e…
Browse files Browse the repository at this point in the history
…lements
  • Loading branch information
LukaFilipovic99 authored and jtomic-croz committed Apr 23, 2024
1 parent ceedd72 commit d385ea8
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions libs/core/src/Breadcrumbs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,28 +54,32 @@ function Breadcrumbs({ children, icon, className, ...props }: BreadcrumbsProps)
tokens.container.borderRadius,
tokens.container.padding,
tokens.container.display,
tokens.container.spaceBetween
tokens.container.spaceBetween,
);

const childContainerClassName = cx(
tokens.childContainer.display,
tokens.childContainer.alignItems,
tokens.childContainer.spaceBetween
tokens.childContainer.spaceBetween,
);

const breadcrumbIcon = useIcon("breadcrumbs", icon, { className: tokens.iconColor });

return (
<nav className="flex">
<ol className={containerClassName}>
{React.Children.map(children, (child, index) => (
<li key={index} className="flex">
<div className={childContainerClassName}>
{index > 0 && React.cloneElement(breadcrumbIcon)}
{child}
</div>
</li>
))}
{React.Children.map(
children,
(child, index) =>
child && (
<li key={index} className="flex">
<div className={childContainerClassName}>
{index > 0 && React.cloneElement(breadcrumbIcon)}
{child}
</div>
</li>
),
)}
</ol>
</nav>
);
Expand All @@ -91,7 +95,7 @@ function Breadcrumb({ children, ...props }: BreadcrumbProps) {
tokens.breadcrumb.color,
tokens.breadcrumb.hover,
tokens.breadcrumb.transitionDuration,
tokens.breadcrumb.transitionTimingFunction
tokens.breadcrumb.transitionTimingFunction,
);

return <span className={breadcrumbClassname}>{children}</span>;
Expand Down

0 comments on commit d385ea8

Please sign in to comment.