1

The code below has 2 buttons, one for an alert, and one for a popup. The problem is that if you bring up the popup, then click the alert, you don't see an alert. Even after "clearing" the popup, you will never see an alert. However, if you bring up the popup, and clear it, then click the alert, that works fine. This is all on an ipad simulator as that is where a popup is sized according to content (so it can share the UI with many elements).

Of course, this is a simplified example. In my real code the button that brings up the alert is nowhere near the one for bringing up the popup (both UI-wise, and code-wise).

It's like i need some sort of global function that says something like "clear all popups" or something? Or maybe use something other than popover? I don't even know if this is a "bug" or a "feature"..

struct ContentView: View {
    @State private var showPopover = false
    @State private var showingAlert = false
    
    var body: some View {
        VStack {
            Spacer()
            Button {
                showingAlert = true
            } label: {
                Text("Click to show alert")
            }
            .alert("Alerted!", isPresented: $showingAlert) {
                Button("OK", role: .cancel) {}
            }.padding()
            Spacer()
            Button("Click to show popover", action: {
                self.showPopover = true
            })
            .popover(isPresented: $showPopover) {
                Text("Popup Text")
            }
            Spacer()
        }
    }
}

I also see these messages in the console while all this is going on.

2022-04-06 12:43:28.494902-0700 TestBee[39557:16837171] [UIFocus] Failed to update focus with context <UIFocusUpdateContext: 0x600001440b40: previouslyFocusedItem=(null), nextFocusedItem=(null), focusHeading=None>. No additional info available.
Jack
  • 2,206
  • 3
  • 18
  • 25
  • I can confirm the behaviour. This seems like a bug. The errror message "Attempt to present .... on .... from ... which is already presenting" suggests the `popover` is not dismissed while the view tries to present the `alert`. – burnsi Apr 06 '22 at 23:53

0 Answers0