Alert is broken on macOS if you resize the window while shown?

Anybody seen this/have any ideas? On macOS if you present an Alert, if your window is resizable and you happen to resize it while the alert is shown, it doesn't dismiss easily. Instead, the Alert continues to pop back up. It will eventually stop doing this, and how many times the alert reshows itself before giving up is directly proportional to how long you spend resizing the window.

Super short program to illustrate it (and this is using Swift lifecycle for a macOS app):

struct ContentView: View {
    @State var showWarning = false
    
    var body: some View {
        VStack {
            Spacer()
            Text("Hello, world!").padding()
            Button("Warn") {
                showWarning = true
            }
            Spacer()
        }.alert(isPresented: $showWarning) {
            Alert(title: Text("tite"), message: Text("message"),
                  dismissButton: .default(Text("OK")))
        }.frame(minWidth: 400, maxWidth: 800,
                    minHeight: 400, maxHeight: 800)
    }
}

Seems to be a bug in SwiftUI. Even changing the order of .alert and .frame doesn't bring any changes.

Terms of Service

Privacy Policy

Cookie Policy