fix(web): close mobile sidebar on navigation#2390
fix(web): close mobile sidebar on navigation#2390jappyjan wants to merge 1 commit intopingdotgg:mainfrom
Conversation
The offcanvas sidebar drawer stayed open after creating a thread or opening one from the list, forcing a manual second tap to dismiss it. Subscribe to the router pathname at the layout level and close the mobile drawer on every route change, so all navigation entry points (thread list, command palette, new-thread hook, keybindings) share the fix. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
📝 WalkthroughWalkthroughThe Changes
Sequence DiagramsequenceDiagram
participant User
participant Router
participant CloseMobileSidebarOnNavigate
participant Sidebar
User->>Router: Navigate to new route
Router->>CloseMobileSidebarOnNavigate: Pathname changes
CloseMobileSidebarOnNavigate->>Sidebar: Check sidebar state
Sidebar-->>CloseMobileSidebarOnNavigate: Is mobile mode & open?
alt Mobile and Open
CloseMobileSidebarOnNavigate->>Sidebar: Close sidebar
Sidebar-->>User: Sidebar closes
else Not mobile or already closed
CloseMobileSidebarOnNavigate-->>User: No action needed
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
ApprovabilityVerdict: Approved This is a straightforward UI bug fix that closes the mobile sidebar when users navigate to a new page. The change is self-contained, uses standard React patterns, and has no security or backend implications. You can customize Macroscope's approvability policy. Learn more. |
Summary
The offcanvas mobile sidebar drawer stays open after creating a thread or selecting one from the list, forcing a manual second tap to dismiss it before reaching the chat. Subscribe to the TanStack Router pathname at the layout level and close the mobile drawer on every route change.
Why this approach
Sidebar.tsx,useHandleNewThread, command palette navigation, and keybindings all callrouter.navigate(...)separately. A single layout-level subscription catches every entry point without touching each handler, and any future navigation paths inherit the fix automatically. Desktop is unaffected because of theisMobileguard.Test plan
Screenshots / video
ScreenRecording_04-28-2026.23-45-30_1.mp4
Reproduction: I run `t3 serve --host "$(tailscale ip -4)"` on a Macbook and use the web UI from an iPhone over Tailscale. This is the first of four small mobile-usability fixes I plan to open separately per the small-and-focused guidance in CONTRIBUTING.md.
Note
Close mobile sidebar on navigation in
AppSidebarLayoutAdds a
CloseMobileSidebarOnNavigatecomponent in AppSidebarLayout.tsx that watches the current pathname viauseRouterState(). When the pathname changes and the sidebar is open on mobile, it callssetOpenMobile(false)to dismiss it.Macroscope summarized d666cb7.
Note
Low Risk
Low risk UI behavior change confined to the sidebar layout; it only toggles
openMobileon pathname changes and is gated byisMobile. Main risk is unintended sidebar dismissal if some navigations shouldn’t close the drawer.Overview
Ensures the off-canvas mobile sidebar drawer automatically closes whenever the route pathname changes.
This adds a small layout-level listener (
CloseMobileSidebarOnNavigate) inAppSidebarLayout.tsxthat subscribes to TanStack RouteruseRouterState()and callssetOpenMobile(false)when navigating, leaving desktop behavior unchanged.Reviewed by Cursor Bugbot for commit d666cb7. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit