Sheet dismiss gesture with swipe back gesture causes app to freeze

Viewed 231

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")
                        }
                    }
                }
            }
        }
    }
}

Here is a gif of the issue in the simulator. First showing the issue, then showing that if you background the app, it resolves on it's own.

enter image description here

0 Answers
Related