Skip to content

fix: make sidebar toggle an externally-provided component via ComponentContext#3088

Open
oliverlaz wants to merge 3 commits intomasterfrom
fix/hide-toggle-sidebar-without-channel-list
Open

fix: make sidebar toggle an externally-provided component via ComponentContext#3088
oliverlaz wants to merge 3 commits intomasterfrom
fix/hide-toggle-sidebar-without-channel-list

Conversation

@oliverlaz
Copy link
Copy Markdown
Member

@oliverlaz oliverlaz commented Apr 2, 2026

🎯 Goal

The ToggleSidebarButton was baked into the SDK, rendering in all header components unconditionally. When there was no ChannelList rendered, the button was pointless. Rather than adding detection logic, this PR removes the built-in toggle entirely and makes it an externally-provided component via a SidebarToggle slot in ComponentContext. Apps define their own toggle behavior and provide it once via WithComponents.

🛠 Implementation details

SDK changes:

  • Added SidebarToggle slot to ComponentContextValue — a simple React.ComponentType with no props contract
  • All 4 headers render the slot conditionally:
    • ChannelHeader / ThreadHeader: render when sidebar is collapsed (!navOpen)
    • ChannelListHeader: render when a channel is active (!!channel)
    • ThreadListHeader: render when a thread is active (!!activeThread)
  • Deleted ToggleSidebarButton component (was not part of the public API)
  • Removed IconSidebar from the SDK icon set (only consumer was the deleted component)
  • Removed MenuIcon prop from ChannelHeader and ThreadHeader
  • Removed ToggleButtonIcon prop from ChannelListHeader and ThreadListHeader

Vite example:

  • Added SidebarToggle component using createIcon for IconSidebar and useChatContext for toggle behavior
  • Registered via WithComponents overrides

Tests:

  • Added SidebarToggle slot tests for ChannelHeader, ChannelListHeader, and ThreadListHeader
  • Removed obsolete toggle button tests and mocks

🎨 UI Changes

No visual changes when SidebarToggle is provided — the toggle renders in the same header positions as before. When not provided, no toggle button appears in any header.

… rendered

The expand button in ChannelHeader is pointless when there is no
ChannelList in the component tree. Use the existing ChannelListContext
to detect whether a ChannelList is present and conditionally render
the button.
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 2, 2026

Size Change: -1.14 kB (-0.19%)

Total Size: 612 kB

📦 View Changed
Filename Size Change
dist/cjs/emojis.js 2.96 kB +2 B (+0.07%)
dist/cjs/index.js 236 kB -525 B (-0.22%)
dist/cjs/WithAudioPlayback.js 42.4 kB -32 B (-0.08%)
dist/es/emojis.mjs 2.47 kB -1 B (-0.04%)
dist/es/index.mjs 235 kB -537 B (-0.23%)
dist/es/WithAudioPlayback.mjs 42.2 kB -46 B (-0.11%)
ℹ️ View Unchanged
Filename Size
dist/cjs/audioProcessing.js 1.32 kB
dist/cjs/mp3-encoder.js 1.27 kB
dist/css/emoji-replacement.css 456 B
dist/css/index.css 45.4 kB
dist/es/audioProcessing.mjs 1.31 kB
dist/es/mp3-encoder.mjs 756 B

compressed-size-action

Verify the button is hidden without ChannelList and shown with it.
Update existing tests to provide ChannelListContext where needed.
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.45%. Comparing base (7b5835e) to head (968e6f2).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3088      +/-   ##
==========================================
- Coverage   79.53%   79.45%   -0.09%     
==========================================
  Files         426      425       -1     
  Lines       12174    12163      -11     
  Branches     3916     3909       -7     
==========================================
- Hits         9683     9664      -19     
- Misses       2491     2499       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…nent

Remove ToggleSidebarButton from the SDK and replace it with a
SidebarToggle slot in ComponentContext. Apps provide their own toggle
component via WithComponents; the SDK renders it in the appropriate
header slots with conditional visibility:

- ChannelHeader/ThreadHeader: render when sidebar is collapsed
- ChannelListHeader: render when a channel is active
- ThreadListHeader: render when a thread is active

Also removes IconSidebar (moved to vite example), MenuIcon prop
from ChannelHeader/ThreadHeader, and ToggleButtonIcon prop from
ChannelListHeader/ThreadListHeader.
@oliverlaz oliverlaz changed the title fix(ChannelHeader): hide toggle sidebar button when no ChannelList is rendered feat: make sidebar toggle an externally-provided component via ComponentContext Apr 3, 2026
@oliverlaz oliverlaz changed the title feat: make sidebar toggle an externally-provided component via ComponentContext fix: make sidebar toggle an externally-provided component via ComponentContext Apr 3, 2026
<ToggleSidebarButton mode='expand'>
<MenuIcon />
</ToggleSidebarButton>
{!navOpen && SidebarToggle && <SidebarToggle />}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oliverlaz navOpen state is used in many places to coordinate the channel list / thread list display, so not sure we can remove it. On the other hand we need to make sure we document how sidebar display should be handled in the docs probably - some cookbook. WDYT?

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.

2 participants