Skip to content

feat: add destroy menubar capability#5

Merged
afonsojramos merged 2 commits into
mainfrom
feat/destroy-menubar
May 9, 2026
Merged

feat: add destroy menubar capability#5
afonsojramos merged 2 commits into
mainfrom
feat/destroy-menubar

Conversation

@afonsojramos
Copy link
Copy Markdown
Member

Summary

  • Adds a destroy() method that removes all tray and app listeners, destroys the underlying BrowserWindow, and prevents the window from opening again until a new Menubar instance is created.
  • Adds an isDestroyed() accessor reporting the destroyed state.
  • Refactors clicked, onAppReady, and onAppActivate into arrow-function class fields so they have stable references and can be removed from event emitters by reference.
  • Documents the new methods in the README.
  • Adds tests for destroy() / isDestroyed() and extends the electron mock with destroy / removeListener.

Adapted from the upstream PR max-mapper/menubar#323 by @typologist, which fixes maxogden/menubar#281.

Test plan

  • bun run test — all tests pass
  • bun run typecheck — no errors
  • bun run lint:check — no new warnings (one pre-existing warning unrelated to this PR)
  • bun run build — produces ESM/CJS bundles

afonsojramos and others added 2 commits May 10, 2026 00:07
Adds a `destroy()` method which removes all event listeners and
prevents the window from opening after that, until a new instance is
created. Also adds an `isDestroyed()` accessor.

Adapted from upstream PR max-mapper#323.

Co-authored-by: Jimmy <3059814+typologist@users.noreply.github.com>
When `app.isReady()` is true at construction time, `onAppReady` is
scheduled via `process.nextTick`, which `destroy()` cannot cancel by
removing a listener. Short-circuit `onAppReady` when `_isDestroyed` is
already set so a sync construct-then-destroy pattern doesn't recreate
the tray and window on the next tick.

Also tightens the mocks into spies and adds spec assertions that
`destroy()` actually removes the tray and app listeners, and that a
second `destroy()` is a true no-op.
@afonsojramos afonsojramos merged commit 068d755 into main May 9, 2026
4 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.

Destroy Menubar

1 participant