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: remove breadcrumbs with empty title #1445

Merged
merged 2 commits into from
Sep 11, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,6 @@ export function createBreadcrumbs(nodes: NavigationNode[]): readonly NavigationB
});
});

return breadcrumb;
// Remove breadcrumbs with empty titles
return breadcrumb.filter((item) => item.title.trim().length > 0);
}
5 changes: 3 additions & 2 deletions packages/ui/app/src/components/FernBreadcrumbs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ export interface FernBreadcrumbsProps {

export function FernBreadcrumbs({ breadcrumbs }: FernBreadcrumbsProps): ReactElement | null {
const toHref = useToHref();
const filteredBreadcrumbs = breadcrumbs.filter((item) => item.title.trim().length > 0);

if (breadcrumbs.length === 0) {
if (filteredBreadcrumbs.length === 0) {
return null;
}
return (
<div>
<span className="fern-breadcrumbs">
{breadcrumbs.map((breadcrumb, idx) => (
{filteredBreadcrumbs.map((breadcrumb, idx) => (
<Fragment key={idx}>
{idx > 0 && <NavArrowRight className="fern-breadcrumbs-arrow" />}
{breadcrumb.pointsTo != null ? (
Expand Down
Loading