Repository navigation
fix(sidebar): stop delaying every click in the sidebar - #258
barto95100 wants to merge 2 commits into
Conversation
[Medium impact] The change affects click and window-zoom behavior in the sidebar. The PR appears safe to merge with a non-blocking regression in double-click zoom below the tabs. Findings
SummaryMoves the sidebar’s double-click gesture behind its controls to avoid delaying single clicks.
Reviews (1) · Last reviewed commit: "fix(sidebar): stop delaying every click ..." · Reviewed by Greptile |
| onAddNewTab: addNewTab | ||
| ) | ||
| .frame(minHeight: scrollArea.size.height, alignment: .top) | ||
| .modifier(DoubleClickToZoomWindow()) |
There was a problem hiding this comment.
Empty-space zoom stops working
The new DoubleClickToZoomWindow inside ContainerView reads a nil window, so double-clicking below the tabs does nothing. NSPageView creates this content in a separate NSHostingView. The closure in SidebarView passes environment objects but not the custom \.window value, which defaults to nil.
Pass window into the hosted content explicitly so this gesture can call toggleMaximized().
There was a problem hiding this comment.
Good catch: the spaces' pages are hosted in their own NSHostingView by NSPageView, so \.window may be nil there. The gesture now zooms the window the double click happened in (NSApp.currentEvent?.window), with the environment value as a fallback. Tested: double click under the last tab zooms the window, in every space.
Summary
Every click in the sidebar (selecting a tab, a space, a pinned tab…) was handled about half a second late.
The double-click gesture that zooms the window (
.onTapGesture(count: 2)inSidebarView) wrapped the whole sidebar. A single tap inside a view that also has a double-tap gesture must wait for the double-click interval before SwiftUI knows it is not a double click, so every tab selection waited too. Measured with timestamps: the state change and redraw take ~2 ms after the tap is recognized; the wait is entirely before it.DoubleClickToZoomWindow, a background with the gesture), so it only catches clicks on the sidebar's empty space and no longer delays the controls.GeometryReader+minHeight), so the empty space under the last tab still zooms the window on a double click, as before.Type of Change
Screenshots / Recordings (if applicable)
Not visual: clicks now respond immediately.
AI Assistance Disclosure
Code written with Claude (AI) under my direction; I reviewed and tested every change on macOS.
Checklist
Related Issues
None (found while working on the sidebar).
Additional Notes
Tested on macOS 26: