I’m trying to open a Sheet window inside a MenuBarExtra in SwiftUI. I don’t know why it happens, but clicking inside the Sheet dismisses the MenuBarExtra and is therefore essentially unusable.
I made this minimal example to showcase the problem:
import SwiftUI
struct ContentView: View {
@State var sheetDisplayed: Bool = true
var body: some View {
Text("test")
.padding().frame(minWidth: 500, minHeight: 500).sheet(isPresented: $sheetDisplayed, content: {
VStack{
Text("test2")
Button("click me"){}
}.frame(minWidth: 200, minHeight: 200)
})
}
}
@main
struct MenuBarTestApp: App {
var body: some Scene {
MenuBarExtra {
ContentView()
} label: {
Image(systemName: "circle")
}.menuBarExtraStyle(.window)
}
}
Clicking either on the “click me” button or anywhere inside the Sheet will dismiss the menu bar app. I have confirmed this happens on both macOS 14.6 and 15.
New contributor
malik is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.