Pin Settings sidebar visibility so the toolbar toggle stops teleporting#369
Merged
Conversation
Comment on lines
+55
to
+61
| .onChange(of: columnVisibility) { _, newValue in | ||
| // Snap back to `.all` if something tries to collapse the sidebar. Cheaper than wiring | ||
| // a custom binding and reads as the same intent: the sidebar is never optional here. | ||
| if newValue != .all { | ||
| columnVisibility = .all | ||
| } | ||
| } |
Contributor
There was a problem hiding this comment.
onChange snap-back doesn't suppress the sidebar-collapse animation
.toolbar(removing: .sidebarToggle) removes the UI button, but the system View › Hide Sidebar menu item and its default keyboard shortcut (⌘⌃S) remain active. When a user presses that shortcut, NavigationSplitView starts its collapse animation before onChange fires and resets columnVisibility to .all, producing a visible flash/flicker. The toggle button fix is solid; consider also disabling the sidebar menu command — for example by overriding NSMenuItem for toggleSidebar: in the hosting window, or by intercepting it with a .commands modifier — to make the experience fully seamless.
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.
The default NavigationSplitView toolbar shows a collapse-sidebar toggle that hops between the sidebar header and the detail header as the column visibility changes. In a Settings window the user has no reason to collapse the sidebar, so the safer fix is to pin visibility to
.alland explicitly remove the toggle from both toolbars.Greptile Summary
Pins the
NavigationSplitViewsidebar to always-visible inSettingsContainerViewby holdingcolumnVisibilityat.all, removing the sidebar-toggle toolbar item from both columns, and adding anonChangeguard that snaps visibility back if anything tries to collapse it.onChangesnap-back provides a defensive fallback, but the systemView › Hide Sidebarmenu command and its keyboard shortcut (⌘⌃S) are not suppressed, so users can still trigger a brief collapse animation before the snap-back fires.Confidence Score: 4/5
Safe to merge; the change is narrowly scoped to the Settings window and has no effect on data or navigation correctness.
The toolbar-removal and visibility-pinning approach is correct and well-commented. The one remaining gap is cosmetic: the macOS sidebar keyboard shortcut can still trigger a visible collapse-and-snap animation since the shortcut is not intercepted. This doesn't affect functionality, only polish.
No files require special attention; the single changed file is self-contained and the logic is straightforward.
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[SettingsContainerView appears] --> B[columnVisibility = .all] B --> C[NavigationSplitView renders sidebar + detail] C --> D{Sidebar toggle toolbar button exists?} D -- Before PR --> E[Toggle shown in sidebar or detail header - jumps around] D -- After PR --> F[.toolbar removing .sidebarToggle applied to both columns] F --> G[Toggle removed from title bar] G --> H{Anything tries to collapse sidebar?} H -- No --> I[Sidebar stays visible ✓] H -- Yes e.g. ⌘⌃S keyboard shortcut --> J[columnVisibility changes] J --> K[onChange fires] K --> L[Snap back to .all] L --> IReviews (1): Last reviewed commit: "Pin Settings sidebar visibility so the t..." | Re-trigger Greptile