Fix popover closing instantly on macOS 27 - #97
Merged
Merged
Conversation
The global mouse monitor watched both `.leftMouseUp` and `.leftMouseDown`. On macOS 27 the `.leftMouseUp` of the click that opens the popover is also delivered to that monitor, so `closePopover()` ran immediately after `openPopover()` and the popover flashed shut. Watching `.leftMouseDown` alone keeps outside-click dismissal intact, since a press outside already closes the popover before its release arrives. Fixes #96
There was a problem hiding this comment.
The mask reduction is correctly scoped: outside left-clicks still call closePopover() on mouse-down, while issue #96 records a macOS 27 A/B test confirming that excluding the opening mouse-up prevents the failure. Head CI passes lint, build, and all tests; although those tests cannot exercise OS event routing, the targeted manual evidence and narrow regression surface support approval.
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.
Summary
Fixes #96. On macOS 27, the popover flashes open and closes immediately, which reads as "the app doesn't launch at all" since Allkdic is an LSUIElement app with no Dock icon and no window.
Root Cause
AppDelegate.setupEventMonitor() installs a global mouse monitor matching [.leftMouseUp, .leftMouseDown] that calls closePopover(). Global monitors are documented as not receiving events routed to your own app, but on macOS 27 the .leftMouseUp of the very click that opens the popover is delivered to this monitor anyway. The sequence becomes: status item click -> openPopover() -> .leftMouseUp -> global monitor -> closePopover().
@mirinae312 diagnosed this on #96 with a diagnostic build (log + call stack) and confirmed with an A/B test that excluding .leftMouseUp keeps the popover open on macOS 27. Thanks for narrowing this down!
Fix
Narrow the monitor mask to
.leftMouseDownonly.Outside-click dismissal is unchanged: a press outside the popover already triggers closePopover() before its release ever arrives, so .leftMouseUp was redundant for dismissal. closePopover() also guards on popover.isShown, so a stray mouse-down before the popover is shown is a no-op.
Alternative considered
Removing the global monitor entirely and relying on popover.behavior = .transient, which by documentation closes the popover on outside interaction. Rejected for now: the monitor has been in place since 2014 as the safety net for clicks in other apps, and removing it risks a "popover stays open" regression on some macOS version nobody here can currently test. Narrowing the mask is the smaller, evidence-backed change.
Testing
No automated regression test was added: the monitor is installed inside AppDelegate at launch, and the existing test target only covers pure-logic types — asserting on an NSEvent.EventTypeMask constant would be a tautology.
Fixes #96
Summary by cubic
Fixes the Allkdic popover closing instantly on macOS 27, which made the app seem to never launch (it has no Dock icon or window).
The global mouse monitor listened for both
.leftMouseUpand.leftMouseDownand calledclosePopover(). On macOS 27, the.leftMouseUpof the click that opens the popover also reaches this monitor, so the popover closed right after appearing (#96). Narrowing the monitor to.leftMouseDownonly keeps outside-click dismissal working, because a press outside already closes the popover before its release arrives.Testing
make lintonly reports a pre-existing error in the Tuist-generatedTuistBundle+Allkdic.swift, untouched here.Written for commit dea5355. Summary will update on new commits.