feedback-assistant / reports

Open collection of Apple Feedback Assistant reports

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

orchetect opened this issue · comments

  • 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

I have duplicated the report (FB11987441).

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

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!