Fix desktop sidebar hosting layout glitch#5781
Conversation
Greptile SummaryThis PR removes a single
Confidence Score: 3/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[User clicks on Sidebar] --> B{Window is key?}
subgraph BEFORE["Before PR (with .clickThrough)"]
B1{Window is key?} -->|Yes| C1[ClickThroughHostingView\nhitTest passes through]
B1 -->|No| D1[acceptsFirstMouse = true\nCaptures pending click location]
D1 --> E1[windowDidBecomeKey fires]
E1 --> F1[Synthetic click re-sent\nSidebar item selected ✓]
C1 --> G1[allowsHitTesting check\nSwiftUI dispatches event\nSidebar item selected ✓]
end
subgraph AFTER["After PR (without .clickThrough)"]
B2{Window is key?} -->|Yes| C2[Standard NSHostingView\nhitTest]
B2 -->|No| D2[acceptsFirstMouse = false\ndefault NSHostingView]
D2 --> E2[First click only activates window\nSidebar item NOT selected ✗]
C2 --> G2[allowsHitTesting check\nSwiftUI dispatches event\nSidebar item selected ✓]
end
B --> B1
B --> B2
|
| .opacity(isInSettings ? 0 : 1) | ||
| .allowsHitTesting(!isInSettings) |
There was a problem hiding this comment.
Loss of "accept first mouse" / activation-click behaviour
ClickThroughHostingView served two purposes that are not replicated by .allowsHitTesting:
-
acceptsFirstMouse(for:) → true— allows the first click on the sidebar (when the app window is not the key window) to both activate the window and select the sidebar item in a single gesture. A plainNSHostingViewreturnsfalsehere, so without the wrapper the first click on the sidebar in a non-key window will only focus the window; a second click is then required to actually select an item. -
Pending-click re-dispatch — the
windowDidBecomeKeyhandler inClickThroughHostingViewcaptured the original click location and synthetically re-sent it after the window became key, guaranteeing the sidebar item was activated regardless of the window-focus sequence.
Both mechanisms are lost with this removal. .allowsHitTesting(!isInSettings) only controls SwiftUI-level event dispatch after AppKit has already decided the NSView is the hit target; it does not replace acceptsFirstMouse or the re-dispatch logic.
If the activation-click regression is acceptable as a trade-off for fixing the layout glitch, that should be documented explicitly in the code or PR.
## Summary - remove the custom click-through host wrapper from the desktop sidebar - keep the existing settings fade/hit-testing behavior without the extra hosting layer - address the sidebar icon/label desync still visible after v0.11.130 ## Verification - cd desktop && xcrun swift build -c debug --package-path Desktop
Summary
Verification