Skip to content

Commit dc30f6d

Browse files
committed
fix: hide empty sidebar controls
1 parent 7891e6d commit dc30f6d

2 files changed

Lines changed: 12 additions & 32 deletions

File tree

apps/site/components/withMetaBar.tsx

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,12 @@ const WithMetaBar: FC = () => {
5151
usernames.length > 0 ||
5252
headings.length > 0;
5353

54-
// Always show collapsed rail when right sidebar is collapsed
54+
// If no content, don't render metabar or controls at all
55+
if (!hasContent) {
56+
return null;
57+
}
58+
59+
// Show collapsed rail when right sidebar is collapsed (only if there's content)
5560
if (isRightSidebarCollapsed) {
5661
return (
5762
<CollapsedSidebarRail side="right">
@@ -64,21 +69,6 @@ const WithMetaBar: FC = () => {
6469
);
6570
}
6671

67-
// If no content, show empty metabar area with toggle button
68-
if (!hasContent) {
69-
return (
70-
<div className="flex w-full flex-col border-l border-neutral-200 bg-white dark:border-neutral-900 dark:bg-neutral-950">
71-
<div className="mb-6 flex justify-end pt-6 pr-2">
72-
<SidebarToggleButton
73-
side="right"
74-
isCollapsed={isRightSidebarCollapsed}
75-
onToggle={toggleRightSidebar}
76-
/>
77-
</div>
78-
</div>
79-
);
80-
}
81-
8272
return (
8373
<MetaBar
8474
heading={t('components.metabar.tableOfContents')}

apps/site/components/withSidebar.tsx

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,12 @@ const WithSidebar: FC<WithSidebarProps> = ({ navKeys, context, ...props }) => {
6969
const hasNavigationContent =
7070
mappedSidebarItems.length > 0 && navKeys.length > 0;
7171

72-
// Always show collapsed rail when sidebar is collapsed
72+
// If no navigation content, don't render sidebar or controls at all
73+
if (!hasNavigationContent) {
74+
return null;
75+
}
76+
77+
// Show collapsed rail when sidebar is collapsed (only if there's content)
7378
if (isLeftSidebarCollapsed) {
7479
return (
7580
<CollapsedSidebarRail side="left">
@@ -82,21 +87,6 @@ const WithSidebar: FC<WithSidebarProps> = ({ navKeys, context, ...props }) => {
8287
);
8388
}
8489

85-
// If no navigation content, show empty sidebar with toggle button
86-
if (!hasNavigationContent) {
87-
return (
88-
<div className="flex w-full flex-col border-r border-neutral-200 bg-white dark:border-neutral-900 dark:bg-neutral-950">
89-
<div className="flex justify-end pt-6 pr-3">
90-
<SidebarToggleButton
91-
side="left"
92-
isCollapsed={isLeftSidebarCollapsed}
93-
onToggle={toggleLeftSidebar}
94-
/>
95-
</div>
96-
</div>
97-
);
98-
}
99-
10090
return (
10191
<Sidebar
10292
ref={sidebarRef}

0 commit comments

Comments
 (0)