Skip to content

feat: add trigger option for tray event binding#6

Merged
afonsojramos merged 3 commits into
mainfrom
feat/trigger-option
May 9, 2026
Merged

feat: add trigger option for tray event binding#6
afonsojramos merged 3 commits into
mainfrom
feat/trigger-option

Conversation

@afonsojramos
Copy link
Copy Markdown
Member

@afonsojramos afonsojramos commented May 9, 2026

Summary

Introduces Options.trigger — a 'click' | 'right-click' | 'none' enum that controls which tray event toggles the menubar window. Deprecates the showOnRightClick boolean, which is kept as a fallback for one minor.

trigger: 'none' skips all tray click bindings, enabling the one tray icon, multiple anchored windows pattern: a secondary Menubar instance reuses tray-anchored positioning while the caller drives visibility via showWindow() (typically from a context-menu entry).

Why an enum, not a disableClick boolean

The motivating use case was raised upstream as max-mapper/menubar#485 by @haydendonald, who proposed a disableClick: boolean flag. We're going further:

  • disableClick is a negative-named boolean, and disableClick: false reads as a double-negative.
  • It silently overlaps with the existing showOnRightClick{ showOnRightClick: true, disableClick: true } quietly disables right-click too, since the wrapping if covers both registration paths. The name lies.
  • It's asymmetric: there's no disableDoubleClick or disableRightClick, so the API can't grow cleanly.

A single trigger enum subsumes both flags, is self-documenting, leaves room for future values (e.g. 'double-click'), and gives a clean migration path off showOnRightClick.

Migration

Before After
(default) (default — trigger: 'click')
showOnRightClick: true trigger: 'right-click'
(no equivalent — was upstream PR max-mapper#485) trigger: 'none'

showOnRightClick still works and is honored when trigger is unset; it's marked @deprecated and slated for removal in the next major.

Test plan

  • bun run test — 18 tests pass, including 5 new cases for trigger:
    • default binds click + double-click
    • trigger: 'right-click' binds right-click + double-click, not click
    • trigger: 'none' binds nothing
    • unset trigger falls back to showOnRightClick
    • trigger wins over showOnRightClick when both are set
  • bun run typecheck — clean
  • bun run lint:check — clean (one pre-existing warning, unrelated)
  • bun run build — ESM/CJS bundles produced

Introduces `Options.trigger` ('click' | 'right-click' | 'none') as the
single source of truth for which tray event toggles the menubar window.
Deprecates `showOnRightClick`, which is kept as a fallback when
`trigger` is unset.

`trigger: 'none'` skips the tray click bindings entirely, enabling the
"one tray icon, multiple anchored windows" pattern: instantiate a
secondary Menubar to reuse the tray-anchored positioning while driving
visibility manually via `showWindow()` (e.g. from a context menu).

The motivating use case was raised in upstream max-mapper#485
by @haydendonald as a `disableClick` boolean. An enum subsumes both that
flag and `showOnRightClick`, avoids a double-negative API, and leaves
room for future trigger types.
@afonsojramos afonsojramos merged commit 62872a0 into main May 9, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant