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

FB11984872: MenuBarExtra needs a way to programmatically close presented window when using window style #383

Open
orchetect opened this issue Feb 9, 2023 · 3 comments

Comments

@orchetect
Copy link

  • Date: 2023-02-08
  • Resolution: Open
  • Area: SwiftUI Framework
  • OS: macOS 13.2
  • Type: Suggestion
  • Keywords: menubar menu bar extra statusitem status item nsstatusitem close toggle present presentation popup popover

Description

When using MenuBarExtra on macOS Ventura, there is no way to programmatically hide, show, or toggle the presentation of the menu/window attached to the status item.

Especially in the case of applying the setting .menuBarExtraStyle(.window) there is no way for a control inside that window to dismiss the window.

Expectation

Potentially, we need a isPresented: Binding<Bool> on MenuBarExtra that can allow this. Or some other method that can be propagated into subviews.

Workaround

After many hours of persistence I have found a hacky workaround. But we definitely need a 1st-party native solution.

https://gist.github.com/orchetect/4530f1fffd74ed91bfd832e74e172652

@sindresorhus
Copy link
Member

I have duplicated the report (FB11987441).

@orchetect
Copy link
Author

I spent a couple days and built a small Swift Package that adds this feature. Until Apple (maybe/hopefully) adds it 1st-party.

https://github.com/orchetect/MenuBarExtraAccess

@dgrcode
Copy link

dgrcode commented Oct 7, 2023

It seems there's at least another similar request: #328 (FB10185203)

PS: https://github.com/orchetect/MenuBarExtraAccess worked really well for my use case 👍 Thanks for sharing!

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

4 participants
@sindresorhus @orchetect @dgrcode and others