Skip to content

Commit

Permalink
fix(ui): Fix separator rendering on sidebar
Browse files Browse the repository at this point in the history
Only render the separator after a section if some of
the remaining sections are visible to the user.

Signed-off-by: Johanna Lamppu <johanna.lamppu@doubleopen.org>
  • Loading branch information
lamppu authored and sschuberth committed Oct 21, 2024
1 parent 9abe5eb commit 79ff688
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions ui/src/components/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ export interface SidebarNavProps {
}

export const Sidebar = ({ sections, className, ...props }: SidebarNavProps) => {
// Helper function to determine if there are any visible sections after the given index.
const visibleRemainingSections = (index: number) =>
sections.slice(index + 1).some((section) => section.visible !== false);

return (
<nav className={cn('w-full', className)} {...props}>
<div className='flex flex-col items-start'>
Expand Down Expand Up @@ -108,9 +112,11 @@ export const Sidebar = ({ sections, className, ...props }: SidebarNavProps) => {
</Link>
) : null;
})}
{sections.length > 1 && index < sections.length - 1 && (
<Separator className='my-2' />
)}
{sections.length > 1 &&
index < sections.length - 1 &&
visibleRemainingSections(index) && (
<Separator className='my-2' />
)}
</div>
);
})}
Expand Down

0 comments on commit 79ff688

Please sign in to comment.