Skip to content
Open
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
22 changes: 19 additions & 3 deletions desktop/src/features/sidebar/ui/CustomChannelSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,24 @@ export function SectionActionsMenu({
onSortModeChange?: (mode: ChannelSortMode) => void;
}) {
const triggerRef = useRef<HTMLButtonElement>(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 (
<DropdownMenu onOpenChange={onOpenChange}>
Expand Down Expand Up @@ -245,7 +261,7 @@ export function SectionActionsMenu({
) : null}
{showSort ? (
<>
<DropdownMenuSeparator />
{hasItemsBeforeSort ? <DropdownMenuSeparator /> : null}
<DropdownMenuSub>
<DropdownMenuSubTrigger>
<ArrowUpDown className="h-4 w-4" />
Expand Down Expand Up @@ -273,7 +289,7 @@ export function SectionActionsMenu({
) : null}
{onDeleteSection ? (
<>
<DropdownMenuSeparator />
{hasItemsBeforeDelete ? <DropdownMenuSeparator /> : null}
<DropdownMenuItem
className="text-destructive focus:text-destructive"
onSelect={() => deferMenuAction(onDeleteSection)}
Expand Down