Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected Behavior in 'Tips' Documentation -- re: window.hide() & always-on-top #324

Open
ArthurD opened this issue Feb 17, 2021 · 0 comments

Comments

@ArthurD
Copy link

ArthurD commented Feb 17, 2021

Description

My overarching goal is an app that is a "pure" menubar, targeting specifically macOS users, with the purpose being to show at-a-glance data in the menubar along with additional detail & quick "controls" when the app is open. I want it to function similar to most macOS menubar apps (ie 1Password) -- when focus is lost, the window should hide completely.

The 'Tips' section of the documentation specifies the following:

Use mb.on('focus-lost') if you would like to perform some operation when using the option browserWindow.alwaysOnTop: true

Steps to Reproduce the Problem

  1. Based on the 'tips' part of the README, I used the following code to cause the window to hide when focus is lost:

mb.on('focus-lost', () => { mb.window.hide(); });

  1. With the menubar app open, click anywhere away from the menubar app (causing it to lose focus).
  2. After closing the app via clicking outside of it [ie loss of focus], now attempt to re-open the menubar app via clicking it in the macOS menubar.
  3. Note that it does not open upon clicking it; a second click is required to get it to open.

Expected Behaviour

After closing the app via clicking outside of it [ie loss of focus], any future click on the app in the macOS menubar should re-activate & display the app/window.

Actual Behaviour

After closing the app via clicking outside of it [ie loss of focus], any future click on the app in the macOS menubar will intermittently (seems to toggle/alternate) have no effect / be a no-op click (window does not display). Clicking it a second time opens the window.

Specifications

  • Menubar version: 9.0.2
  • Platform: macOS Big Sur (11.2.1)
  • Electron version: 9.4.3

Other information

It appears that using the following code, instead of the code above, actually causes the behavior to be as expected -- ie it resolves the issue -- so maybe this "issue" can just be 'fixed' via simply updating the documentation, I'm not sure.

mb.on('focus-lost', () => { mb.hideWindow(); });

If nothing else, I'd like to understand why this works & the approach that I tried initially does not; and if there is a way to make my initial approach work I'd love to hear & learn/understand it (ie do I need to call/init the window again somehow, or listen for menubar click manually & call show(), or similar). :)

Thank you very much; this is a fantastic project and I very much appreciate all the work that has gone into it! It's really quite nice -- thank you! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant