fix: make sidebar toggle an externally-provided component via ComponentContext#3088
Open
fix: make sidebar toggle an externally-provided component via ComponentContext#3088
Conversation
… 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.
|
Size Change: -1.14 kB (-0.19%) Total Size: 612 kB 📦 View Changed
ℹ️ View Unchanged
|
Verify the button is hidden without ChannelList and shown with it. Update existing tests to provide ChannelListContext where needed.
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
…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.
MartinCupela
reviewed
Apr 6, 2026
| <ToggleSidebarButton mode='expand'> | ||
| <MenuIcon /> | ||
| </ToggleSidebarButton> | ||
| {!navOpen && SidebarToggle && <SidebarToggle />} |
Contributor
There was a problem hiding this comment.
@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?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🎯 Goal
The
ToggleSidebarButtonwas baked into the SDK, rendering in all header components unconditionally. When there was noChannelListrendered, 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 aSidebarToggleslot inComponentContext. Apps define their own toggle behavior and provide it once viaWithComponents.🛠 Implementation details
SDK changes:
SidebarToggleslot toComponentContextValue— a simpleReact.ComponentTypewith no props contractChannelHeader/ThreadHeader: render when sidebar is collapsed (!navOpen)ChannelListHeader: render when a channel is active (!!channel)ThreadListHeader: render when a thread is active (!!activeThread)ToggleSidebarButtoncomponent (was not part of the public API)IconSidebarfrom the SDK icon set (only consumer was the deleted component)MenuIconprop fromChannelHeaderandThreadHeaderToggleButtonIconprop fromChannelListHeaderandThreadListHeaderVite example:
SidebarTogglecomponent usingcreateIconforIconSidebaranduseChatContextfor toggle behaviorWithComponentsoverridesTests:
SidebarToggleslot tests forChannelHeader,ChannelListHeader, andThreadListHeader🎨 UI Changes
No visual changes when
SidebarToggleis provided — the toggle renders in the same header positions as before. When not provided, no toggle button appears in any header.