Skip to content

fix(desktop): drop orphaned separators from sidebar section menus - #3661

Open
sumit-m wants to merge 1 commit into
block:mainfrom
sumit-m:sidebar-section-menu-separator
Open

fix(desktop): drop orphaned separators from sidebar section menus#3661
sumit-m wants to merge 1 commit into
block:mainfrom
sumit-m:sidebar-section-menu-separator

Conversation

@sumit-m

@sumit-m sumit-m commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

What problem this solves

The sidebar section "more actions" menu (SectionActionsMenu) renders every item
conditionally, but two of its dividers are unconditional. When the items above a
divider all happen to be absent, the menu opens on a divider with nothing
before it
.

The built-in Channels header hits this in normal use. AppSidebar supplies
it only two things that can produce items:

  • onMarkAllRead, itself gated on hasUnread
  • a sort preference (sortMode / onSortModeChange)

"Browse channels" is wired to the adjacent quick-create + button, not into this
menu, and rename/move/delete apply only to user-created sections. So the menu has
two states, and one of them is broken:

state menu
a channel is unread Mark all as read · divider · Sort — correct
everything read divider · Sortorphaned divider

That intermittency is why it reads as "sometimes broken": the divider is correct
right up until you read your last unread channel.

Fix

Compute whether anything actually precedes each divider and render it only then.

Two further points, same bug class, same component:

  • The Delete section divider has the identical flaw. Reachable when a section
    supplies onDeleteSection but no rename/move handlers and no sort preference.
  • showSectionManagement was gated on onRenameSection || onDeleteSection, but
    the block it guards renders rename/move-up/move-down. A delete-only section
    therefore opened the wrapper and emitted nothing — which would in turn make the
    new "is anything above me" check wrong. Now gated on the items it renders.

Verification

Confirmed by state transition in a running dev app rather than by inspection —
opened the Channels menu with unread present, clicked Mark all as read, then
reopened:

unread present  → items: [Mark all as read, separator, Sort]   separators: 1
all read        → items: [Sort]                                separators: 0

tsc --noEmit clean, biome clean, 3781 frontend unit tests pass.

Notes for reviewers

Not platform-specific — nothing here depends on the host, and it reproduces
anywhere the Channels section has no unread items.

Conflict likely with #2947
(sidebar categories and manual channel ordering), which also touches
CustomChannelSection.tsx and AppSidebar.tsx. That PR adds section
reordering, so it may introduce more conditional items above these dividers —
if it lands first, the hasItemsBeforeSort expression here needs its new
handlers added to the list. Happy to rebase behind it.

@sumit-m
sumit-m requested a review from a team as a code owner July 30, 2026 01:03
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>
@sumit-m
sumit-m force-pushed the sidebar-section-menu-separator branch from 92007d2 to effc64f Compare July 31, 2026 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant