From 2c99531bcd3aee0ebdba2b2e2ea9e20385c404be Mon Sep 17 00:00:00 2001 From: sumit-m <33051892+sumit-m@users.noreply.github.com> Date: Thu, 30 Jul 2026 06:33:03 +0530 Subject: [PATCH] fix(desktop): drop orphaned separators from sidebar section menus The Sort and Delete section dividers rendered unconditionally, so a section whose earlier items are all absent opened its menu on a divider with nothing above it. Also gate the section-management block on the items it renders, not on `onDeleteSection`. Signed-off-by: sumit-m <33051892+sumit-m@users.noreply.github.com> --- .../sidebar/ui/CustomChannelSection.tsx | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/desktop/src/features/sidebar/ui/CustomChannelSection.tsx b/desktop/src/features/sidebar/ui/CustomChannelSection.tsx index 7e17ce02ca..f643205039 100644 --- a/desktop/src/features/sidebar/ui/CustomChannelSection.tsx +++ b/desktop/src/features/sidebar/ui/CustomChannelSection.tsx @@ -161,8 +161,24 @@ export function SectionActionsMenu({ onSortModeChange?: (mode: ChannelSortMode) => void; }) { const triggerRef = useRef(null); - const showSectionManagement = Boolean(onRenameSection || onDeleteSection); + // Gate on the items this block actually renders. Including `onDeleteSection` + // here would open the wrapper for a delete-only section and emit nothing. + const showSectionManagement = Boolean( + onRenameSection || onMoveSectionUp || onMoveSectionDown, + ); const showSort = Boolean(sortMode && onSortModeChange); + // Separators are only meaningful with an item above them. The built-in + // Channels header supplies just `onMarkAllRead` (itself gated on unread) and + // a sort preference, so with everything read the menu would otherwise open + // on a divider with nothing before it. + const hasItemsBeforeSort = Boolean( + (hasUnread && onMarkAllRead) || + onNewMessage || + onBrowse || + onCreate || + showSectionManagement, + ); + const hasItemsBeforeDelete = hasItemsBeforeSort || showSort; return ( @@ -245,7 +261,7 @@ export function SectionActionsMenu({ ) : null} {showSort ? ( <> - + {hasItemsBeforeSort ? : null} @@ -273,7 +289,7 @@ export function SectionActionsMenu({ ) : null} {onDeleteSection ? ( <> - + {hasItemsBeforeDelete ? : null} deferMenuAction(onDeleteSection)}