Skip to content

fix: choose a submenu item opened from the App menus tray - #944

Merged
M4n0x merged 2 commits into
stablebox:mainfrom
MaHofseth:fix/942-tray-submenu-click
Nov 27, 2026
Merged

M4n0x merged 2 commits into
stablebox:mainfrom
MaHofseth:fix/942-tray-submenu-click

Conversation

@MaHofseth

@MaHofseth MaHofseth commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Problem

With Expand on hover on and too little room for the menus to expand, App menus open from a tray under the bar. Pressing the mouse in a submenu opened from there closed the tray, and with it the menu and the submenu, before the mouse came up, so the item wasn't chosen.

Fixes #942

Changes

  • The tray's local event monitor ignored only windows whose direct parent is its panel. A menu opened from the tray is the tray's child, and that menu's submenus are the menu's children, so a click in a submenu counted as a click outside. The monitor now also ignores mouse events from any window further up the chain of child windows, through a private NSWindow.isDescendant(of:). Key presses from those windows still reach it, so Escape in such a submenu closes the tray, as on main; the popup's own child windows keep the rule they had.
  • The monitor's logic moved, unchanged apart from this, into WidgetPopup.consumes(_:anchor:), so the test can give an event to one popup.

No configuration property changes, and nothing looks different.

Testing

  • New test aClickInASubmenuLeavesTheTrayItsMenuOpenedFromOpen (AppMenuTrayClickTests.swift) opens a real tray, a menu popup anchored in it and a submenu window attached to the menu, then gives the tray's handler a mouse-down in the submenu. The tray must stay open. Then either Escape in the submenu or a mouse-down in an unrelated window must close it. Without the descendant check, both cases fail.
  • An earlier version of the test used NSApp.sendEvent, which runs every local monitor in the test process, so it closed popups that other tests had open. As the review found, that broke other popup tests in the full runs. This description earlier suggested clicks in other apps, which was wrong.
  • swift build --build-tests, scripts/check.sh --quick and commitlint pass.
  • The popup, tooltip, chooser and app menu tests ran 5 times. Each run failed only the three cases of tooltipsThatTakeThePointerLeaveClicksOnTheirWidgetToIt, which also fail on an unchanged 8590fcd on the same Mac.
  • The full suite (swift test, 1,462 tests) fails only those and workspaceLabelsFollowTheBarFromLightToDark, which also fails on unchanged 8590fcd there. With fix: leave the keyboard with the app while StableBar shows its menus #943 merged too, on 1fe18ea, the full suite (1,476 tests) fails only the same two.
  • Manual check: in VS Code, View > Appearance > Primary Side Bar chosen through the tray ran, and VS Code logged the command. That development build had this pull request's first version and Choosing an app menu item does nothing in VS Code because StableBar's menu takes the keyboard #941's fix, so it doesn't isolate this one or cover the later changes.
  • Manual check of the later changes, with fix: leave the keyboard with the app while StableBar shows its menus #943 merged too, on 1fe18ea: the same item through the tray, chosen twice, toggled the side bar both times. VS Code's Trace log shows both commands and no no active window line. Because the build had both fixes, this doesn't isolate this one. Escape in a submenu wasn't checked by hand.

Merging

One fix and one test commit, so a patch release. A squash merge works best. It merges cleanly with #943, the fix for #941, which changes another part of WidgetPopup.swift.

🤖 Generated with Claude Code

Claude Sonnet 5.5 and Claude Opus 5.5 via Claude Code

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 2 files

You’re at about 98% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact [email protected].

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

The tray ignored clicks only in its direct child windows. A submenu of a menu opened from the
tray sits two windows above it, so a mouse-down there closed the tray, and with it the menu and
the submenu, before the item was chosen. Clicks there now count as inside the tray, while Escape
there still closes it.

Fixes #942

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@MaHofseth
MaHofseth force-pushed the fix/942-tray-submenu-click branch from acc54f7 to e569b6c Compare November 26, 2026 00:23
@M4n0x M4n0x added the deep-review CodeRabbit reviews this pull request: big or risky changes label Nov 26, 2026
@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

WidgetPopup.watchEvents now recognizes windows nested under the popup as inside-popup windows for non-key events. A regression test checks submenu mouse-down behavior and confirms Escape and outside clicks still close the tray.

Changes: Popup event handling

Layer / File(s) Summary
Recognize descendant popup windows
Sources/StableBar/Popups/WidgetPopup.swift, Tests/StableBarTests/AppMenuTrayClickTests.swift
watchEvents checks window ancestry and passes through non-key events from popup descendants. The test verifies that a submenu click leaves the tray open, while Escape or an outside click closes it.

Severity of issue fixed: Medium

Merge Risk: Minimal · up to 50d15

This change lets clicks in tray submenus choose the item instead of closing the tray first. Escape and outside-click dismissal are kept, and no merge-blocking risk was found.

Security architecture risk: Minimal · up to 50d15

Clicks in nested menus no longer dismiss the tray before an item can be selected. Escape and outside clicks still dismiss the tray in the covered cases. The change does not add a public interface or grant new permissions.

Pre-merge checks: Passed 3

Check name Status Explanation
Linked Issues check Passed Directly linked issue #942 requires that a mouse-down in a submenu opened from the App menus tray does not close the tray before mouse-up. The diagnosis in #942 names the tray event monitor in Sources…
Out of Scope Changes check Passed The whole-PR change set has two files. Sources/StableBar/Popups/WidgetPopup.swift gets the tray event-monitor change and a private NSWindow.isDescendant(of:) helper, which directly support #942. Tests…
Description check Passed The description follows the repository template. It has Problem (with Fixes #942), Changes, Testing, Merging, and a final line naming the model and harness. The Problem and Changes sections state the …
Full details: Linked Issues check

Explanation

Directly linked issue #942 requires that a mouse-down in a submenu opened from the App menus tray does not close the tray before mouse-up. The diagnosis in #942 names the tray event monitor in Sources/StableBar/Popups/WidgetPopup.swift, which ignored only windows whose direct parent is the tray. The raw summary and PR description state that the monitor now ignores non-key events from any window descended from the popup panel, using a private NSWindow.isDescendant(of:) helper, and that key events from those windows still reach the Escape handling. The new test aClickInASubmenuLeavesTheTrayItsMenuOpenedFromOpen in Tests/StableBarTests/AppMenuTrayClickTests.swift checks this in the source diff. It sends a mouse-down to a submenu attached two windows above the tray and asserts that tray.consumes(...) is false and tray.isOpen stays true. It sends Escape from the submenu and asserts consumption and closure, and it sends a click elsewhere and asserts closure. Limit: WidgetPopup.swift could not be read at the whole-PR base or head, so the implementation is not verified directly. The test results are author-reported. The test file and the summary agree on the intended behavior. The head changed since the previous review (e569b6c to 50d156d); the Escape-preservation behavior is the change made since then and is covered by the test assertions.

Full details: Out of Scope Changes check

Explanation

The whole-PR change set has two files. Sources/StableBar/Popups/WidgetPopup.swift gets the tray event-monitor change and a private NSWindow.isDescendant(of:) helper, which directly support #942. Tests/StableBarTests/AppMenuTrayClickTests.swift adds one parameterized test for the same tray-submenu behavior. The PR states that no configuration properties or visible appearance change, and it does not touch the notch-fitting work covered by #312 and #453. Limit: WidgetPopup.swift could not be read directly, so the scope of the source hunks is taken from the raw summary and the PR description.

Full details: Description check

Explanation

The description follows the repository template. It has Problem (with Fixes #942), Changes, Testing, Merging, and a final line naming the model and harness. The Problem and Changes sections state the bug, the cause, and the fix in detail. The Testing section lists the tests run, the failures seen, and which failures also occur on unchanged main. It also says what was not checked by hand, including Escape in a submenu. The Merging section says a squash merge works best and names the related PR #943. The final line names the models and harness, as the template requires.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between e569b6c and 50d156d.

Files selected for processing: 2

  • Sources/StableBar/Popups/WidgetPopup.swift
  • Tests/StableBarTests/AppMenuTrayClickTests.swift

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@M4n0x M4n0x left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix looks right to me, walking the whole parent chain is the way to go and Escape still closes the tray like on main. The test needs another approach though, see inline, it's what broke the other popup tests in your full runs (+ worth updating that part of the description once it's changed)

NSApp.sendEvent runs every local monitor in the test process, so the test closed popups that
tests running alongside it had open. The monitor's logic is now WidgetPopup.consumes, which the
monitor and the test both call. The test also drops a check on the menu that could never fail, and
stops at its first failure instead of sending a key press to a closed popup.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Before and after

main at 8590fcd → this pull request at 50d156d · 202 screens drawn · 0 changed

202 unchanged screens

docs/essentials-clock-settings-dark, docs/essentials-clock-settings-light, docs/essentials-dark, docs/essentials-light, docs/essentials-settings-dark, docs/essentials-settings-light, docs/hero-dark, docs/hero-light, docs/popups-dark, docs/popups-light, docs/settings-dark, docs/settings-light, docs/themes-dark, docs/themes-light, scenes/accessibility-guide-dark, scenes/app-menu-popup-dark, scenes/apple-menu-settings-dark, scenes/apple-menu-symbol-bar-dark, scenes/apple-menu-symbol-settings-dark, scenes/bar-dividers-dark, scenes/bottom-bar-popup-dark, scenes/chat-popup-dark, scenes/crowded-edit-bar-dark, scenes/disk-meter-bar-dark, scenes/dock-badges-bar-dark, scenes/edit-bar-wide-group-dark, scenes/essentials-clock-popup-dark, scenes/essentials-disk-popup-dark, scenes/filled-slider-popup-dark, scenes/glass-text-follows-background-bar-dark, scenes/glass-text-follows-background-bar-light, scenes/group-members-bar-dark, scenes/group-others-bar-dark, scenes/group-text-color-bar-dark, scenes/gruvbox-bar-dark, scenes/gruvbox-bar-light, scenes/horizontal-list-popup-dark, scenes/increase-contrast-bar-dark, scenes/increase-contrast-bar-light, scenes/increase-contrast-popup-dark, scenes/increase-contrast-popup-light, scenes/input-source-popup-dark, scenes/labeled-metric-built-in-dark, scenes/labeled-metric-catppuccin-dark, scenes/labeled-metric-catppuccin-light, scenes/meeting-live-popup-dark, scenes/meeting-soon-bar-dark, scenes/menu-bar-items-widget-settings-dark, scenes/menu-bar-items-widget-style-dark, scenes/merged-status-bar-dark, scenes/notch-flare-bar-dark, scenes/output-device-popup-dark, scenes/package-template-clash-bar-dark, scenes/popup-gap-bar-dark, scenes/popup-spacing-bar-dark, scenes/popup-view-dark, scenes/preset-dashboard-bar-dark, scenes/preset-developer-bar-dark, scenes/preset-everyday-bar-dark, scenes/preset-minimal-bar-dark, scenes/preset-workday-bar-dark, scenes/privacy-both-bar-dark, scenes/privacy-hide-when-idle-bar-dark, scenes/privacy-idle-bar-dark, scenes/privacy-microphone-bar-dark, scenes/privacy-settings-dark, scenes/quick-toggles-bar-dark, scenes/quick-toggles-displays-popup-dark, scenes/quick-toggles-every-tile-popup-dark, scenes/quick-toggles-network-popup-dark, scenes/quick-toggles-networks-popup-dark, scenes/quick-toggles-popup-dark, scenes/reduce-transparency-bar-dark, scenes/reduce-transparency-bar-light, scenes/reduce-transparency-glass-bar-dark, scenes/reduce-transparency-glass-bar-light, scenes/reduce-transparency-text-follows-background-bar-dark, scenes/reduce-transparency-text-follows-background-bar-light, scenes/ring-bar-dark, scenes/settings-bar-dark, scenes/settings-bar-link-dark, scenes/settings-bar-link-review-dark, scenes/settings-bar-link-workspace-color-dark, scenes/settings-bar-look-dark, scenes/settings-bar-look-light, scenes/settings-bar-placement-bottom-dark, scenes/settings-bar-placement-dark, scenes/settings-calendar-picker-dark, scenes/settings-calendar-widget-dark, scenes/settings-clock-widget-dark, scenes/settings-crashes-dark, scenes/settings-disk-widget-dark, scenes/settings-feedback-dark, scenes/settings-general-dark, scenes/settings-general-kiwidesk-dark, scenes/settings-general-macos15-dark, scenes/settings-general-macos27-dark, scenes/settings-general-manager-not-found-dark, scenes/settings-general-move-dark, scenes/settings-general-move-failed-dark, scenes/settings-general-move-moving-dark, scenes/settings-general-move-replace-dark, scenes/settings-general-setup-open-dark, scenes/settings-general-spaces-dark, scenes/settings-general-yabai-gap-dark, scenes/settings-group-dark, scenes/settings-group-defaults-dark, scenes/settings-group-defaults-light, scenes/settings-group-theme-color-dark, scenes/settings-group-theme-color-light, scenes/settings-help-dark, scenes/settings-help-starred-dark, scenes/settings-labeled-metric-dark, scenes/settings-narrow-dark, scenes/settings-package-dark, scenes/settings-package-widget-dark, scenes/settings-profiles-conditions-dark, scenes/settings-profiles-dark, scenes/settings-profiles-groups-dark, scenes/settings-profiles-theme-dark, scenes/settings-quick-toggles-dark, scenes/settings-store-dark, scenes/settings-theme-dark, scenes/settings-theme-edits-dark, scenes/settings-theme-edits-light, scenes/settings-theme-groups-dark, scenes/settings-theme-light, scenes/settings-theme-link-dark, scenes/settings-theme-link-light, scenes/settings-theme-origins-dark, scenes/settings-theme-versions-dark, scenes/settings-tiled-dark, scenes/settings-tiled-narrowest-dark, scenes/settings-uninstall-dark, scenes/settings-uninstall-failed-dark, scenes/settings-widget-backgrounds-dark, scenes/settings-widget-backgrounds-light, scenes/settings-widget-colors-dark, scenes/settings-widget-colors-light, scenes/settings-widget-style-theme-edits-dark, scenes/settings-widget-style-theme-edits-light, scenes/settings-workspace-hidden-dark, scenes/setup-allow-aerospace-gap-dark, scenes/setup-allow-automation-dark, scenes/setup-allow-below-menu-bar-dark, scenes/setup-allow-dark, scenes/setup-allow-dot-dark, scenes/setup-allow-macos27-dark, scenes/setup-allow-offline-dark, scenes/setup-allow-spaces-dark, scenes/setup-allow-workday-dark, scenes/setup-choose-dark, scenes/setup-choose-new-dark, scenes/setup-choose-no-battery-dark, scenes/setup-done-dark, scenes/setup-intro-dark, scenes/setup-intro-wallpaper-dark, scenes/setup-move-existing-dark, scenes/setup-move-failed-dark, scenes/setup-move-ready-dark, scenes/setup-move-replace-dark, scenes/shadow-offsets-bar-dark, scenes/shadow-offsets-bar-light, scenes/share-my-bar-dark, scenes/share-my-bar-dock-dark, scenes/share-my-bar-glass-dark, scenes/share-my-bar-glass-light, scenes/share-my-bar-landscape-dark, scenes/share-my-bar-link-dark, scenes/share-my-bar-macbook-dark, scenes/share-my-bar-post-dark, scenes/slider-end-stop-popup-dark, scenes/sound-details-popup-dark, scenes/stablebar-widget-bar-dark, scenes/stablebar-widget-settings-dark, scenes/starter-bar-dark, scenes/starter-edit-bar-dark, scenes/symbol-variants-bar-dark, scenes/system-monitor-memory-bar-dark, scenes/system-monitor-shows-settings-dark, scenes/system-monitor-split-warning-bar-dark, scenes/text-follows-background-bar-dark, scenes/text-follows-background-bar-light, scenes/themed-slider-inline-dark, scenes/themed-slider-inline-light, scenes/themed-slider-popup-dark, scenes/themed-slider-popup-light, scenes/themed-slider-tooltip-dark, scenes/themed-slider-tooltip-light, scenes/tinted-app-icons-bar-dark, scenes/tinted-app-icons-bar-light, scenes/tinted-image-bar-dark, scenes/tinted-image-bar-light, scenes/update-popup-dark, scenes/update-popup-star-github-cli-dark, scenes/update-popup-star-thanks-dark, scenes/workspace-badges-bar-dark, scenes/workspace-cells-bar-dark, scenes/workspace-focused-window-bar-dark, scenes/workspace-focused-window-padding-bar-dark, and 2 more

Visual review: 202 screens, none changed.

@M4n0x M4n0x left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, reads better with consumes too. Tried it in a VM with VS Code, View > Appearance > Status Bar from the tray toggles it now (on main the tray just closes), and Escape in the submenu still closes everything

@M4n0x
M4n0x added this pull request to the merge queue Nov 27, 2026
Merged via the queue into stablebox:main with commit add49b0 Nov 27, 2026
25 checks passed
stablebar-releases Bot pushed a commit that referenced this pull request Nov 29, 2026
## [0.20.0](v0.19.0...v0.20.0) (2026-11-29)

### Features

* animate widgets that a profile shows or hides ([#948](#948)) by @M4n0x ([eec8544](eec8544)), closes [#947](#947) [#947](#947)
* log quit causes and show unexpected quits in Status ([#953](#953)) by @M4n0x ([ea5a64e](ea5a64e)), closes [#952](#952)

### Bug Fixes

* choose a submenu item opened from the App menus tray ([#944](#944)) by @MaHofseth ([add49b0](add49b0)), closes [#942](#942)
* draw borders in whole pixels so they keep every edge on 1x screens ([#934](#934)) by @M4n0x ([8590fcd](8590fcd)), closes [#933](#933) [#933](#933)
* keep a package version installed when its folder is hidden ([#962](#962)) by @M4n0x ([2d97d15](2d97d15)), closes [#961](#961)
* keep the Sound details open and smooth when picking a device ([#931](#931)) by @M4n0x ([df96453](df96453)), closes [#928](#928) [#928](#928)
* keep windows clear of the bar after a double-click fills them ([#936](#936)) by @M4n0x ([c1478d1](c1478d1)), closes [#935](#935) [#935](#935)
* leave the keyboard with the app while StableBar shows its menus ([#943](#943)) by @MaHofseth ([abc1c4f](abc1c4f)), closes [#941](#941)
* play an app's first sound at its mixer volume ([#899](#899)) by @M4n0x ([2c38350](2c38350)), closes [#897](#897) [#897](#897)
* show a turned-off widget's last output when it comes back ([#950](#950)) by @M4n0x ([6776fcb](6776fcb)), closes [#949](#949) [#949](#949)
* show Countdown and Join in Settings after picking it ([#940](#940)) by @MaHofseth ([6ecaa72](6ecaa72))
* stop offering a package update that is already installed ([#956](#956)) by @M4n0x ([4592ebc](4592ebc))
@stablebar-releases

Copy link
Copy Markdown

🎉 This PR is included in version 0.20.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deep-review CodeRabbit reviews this pull request: big or risky changes released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clicking a submenu item from the App menus tray closes the menus without choosing it

2 participants