fix: lock the toolbar to icon-only so the sidebar toggle can't fold into the overflow menu#85
Merged
Merged
Conversation
…nto the overflow menu The toolbar's right-click menu offered Icon and Text / Text Only modes, but SwiftUI's NavigationSplitView toolbar doesn't survive them: AppKit folds the system sidebar-toggle item into the overflow (>>) menu at the trailing edge and grows the titlebar without showing any useful labels. The folding happens inside SwiftUI's private toolbar items, so there is no supported way to make the label modes render correctly. Opt out via NSToolbar.allowsDisplayModeCustomization (the macOS 15 API added for exactly this case) and force displayMode back to .iconOnly to repair a mode picked before the lock existed. Applied from WindowAppearance.sync, which already re-applies window chrome idempotently on launch, become-main, and fullscreen transitions.
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.
What
Right-clicking the toolbar offered Icon and Text / Icon Only / Text Only display modes. Picking Icon and Text broke the toolbar: the sidebar toggle disappeared from its top-left spot and folded into the overflow (») menu at the trailing edge, and the titlebar grew taller without showing any useful labels.
This locks the toolbar to icon-only rendering and removes those context-menu options via
NSToolbar.allowsDisplayModeCustomization = false.Why
The breakage is a framework-level issue, not something we can style around:
NavigationSplitViewowns the sidebar-toggle toolbar item, and SwiftUI's toolbar items misreport their size in the label display modes, so AppKit folds the toggle into overflow even with plenty of room. Reproduced and confirmed by opening the overflow menu — “Hide Sidebar” was inside it.allowsDisplayModeCustomizationis the macOS 15+ API Apple added for exactly this case (apps whose unified toolbars don't support text labels opt out — Notes, Reminders, etc. don't offer the menu at all). ForcingdisplayMode = .iconOnlyadditionally repairs the state for anyone who already switched modes before the lock existed.How
A new
syncToolbar(window:)inWindowAppearance, called fromWindowAppearance.sync— which already re-applies window chrome idempotently on launch, become-main, fullscreen transitions, and config changes, so the lock applies once the toolbar exists and stays applied if AppKit rebuilds it.Verified
mise run format,lint, andtestall pass.🤖 Generated with Claude Code