Sheet dismiss gesture with swipe back gesture causes app to freeze

I found a strange and frustrating behavior in SwiftUI. If you present a sheet from within a view in a navigation link and then (quickly and in order):

  1. swipe down to dismiss the sheet
  2. swipe back (from left edge to the right) to dismiss the navigation view

The app will freeze before going back to the root view. Backgrounding the app and foregrounding it will unstick it.

You have to perform the steps very quickly. Is there a workaround? I would like both gestures to work without interfering with each other.

This code will reproduce the issue:

struct ContentView: View {
    @State var showSheet = false
    
    var body: some View {
        NavigationView {
            VStack {
                NavigationLink("blah") {
                    VStack {
                        Button("Show Sheet") {
                            showSheet.toggle()
                        }
                        .sheet(isPresented: $showSheet, onDismiss: nil) {
                            Text("Sheet")
                        }
                    }
                }
            }
        }
    }
}

There is a gif linked in the Stack Overflow question demonstrating the problem.

Post not yet marked as solved Up vote post of brian-dateit Down vote post of brian-dateit
1.8k views
  • Apple's native SwiftUI apps have this issue, like Podcasts (on iOS 16 it's made with SwiftUI, I don't know about older versions)

Add a Comment

Replies

I have the exact same problem. It is pretty random. Did you ever fix this?

I have experienced the same issue as you, but I haven't been able to resolve it. It seems to happen randomly. Have you found a solution?

Facing the same issue. Still not resolved