Repository navigation
fix: open SwiftUI menu bar panels from the bar on macOS 27 - #904
Conversation
A menu bar item whose menu the bar doesn't draw got a press through Accessibility. SwiftUI menu bar extras that open a window ignore that press, so their panels, such as Spectra's, never opened from the bar. Left clicks now go to MenuBarAgent's menu bar window as a real click, the way the experimental right-click already does. Where no such window is found, the item still gets the press. Right-clicking stays opt-in. Fixes #798
|
No actionable comments were generated in the recent review. Walkthrough
Severity of issue fixed: Medium Merge Risk:
|
Before and after
265 unchanged screens
Visual review: 265 screens, none changed. |
|
🎉 This PR is included in version 0.19.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Problem
On macOS 27, clicking a menu bar item on the bar, or in the Menu bar items row, pressed it through Accessibility. SwiftUI menu bar extras that open a window (
.menuBarExtraStyle(.window)) ignore that press, so their panels never opened from StableBar. Spectra's menu bar panel is one of them.Fixes #798
Changes
AppMenu.pressInMenuBarnow sends a left click to MenuBarAgent's menu bar window throughclickInMenuBar(formerlyrightClickInMenuBar, now given the button). The events and the window lookup are the experimental right-click's (feat: right-click a menu bar item on the bar as in the macOS menu bar #761, fix: right-click a menu bar item on a notched display without moving the pointer #774), so no new private call.MenuBarMouse.rightClickbecomesclick(point, window, button), andmenuBarRightClickbecomesmenuBarClick(at:in:button:).rightClickInMenuBar, and it still waits for the right button to come up. With it off, a right-click acts like a click, so it now clicks too.No configuration change. The guide already says these items open their own panel or menu, so the docs stay as they are.
Testing
New tests in
BarContextMenuTests:Three of them fail with the old press. The existing right-click tests now check the button.
BarContextMenuTests,ArchitectureRulesTests,NativePresentationTestsand theAppMenutests pass locally, and so doesscripts/check.sh --quick. CI runs the full suite.In a macOS 27.2 tart VM (cirruslabs' Golden Gate image), with the menu bar hiding automatically, a test app with one SwiftUI
.windowextra and one.menuextra, and Spectra 0.9.21 Free:mainControl Center and Clock were checked with an earlier build that sends the same click.
main: click on the panel's itemIn that VM, synthetic clicks never fire the SwiftUI gesture the bar's items use to act on mouse-down, so the left-click checks used a build whose gesture also triggers on
perform, which fires at mouse-down too. Right-clicks ran the unchanged code.Not checked:
anItemGetsAPressWhereAClickCanNotBeSentToTheMenuBarcovers.Separate and not fixed: holding the button down 700 ms or more makes Spectra Free's menu close on release, on
maintoo.Merging
One commit; any merge method keeps it.
Claude Opus 5.5 via Claude Code