Case study presenting a view controller from a detached view controller freezes #1409
Replies: 2 comments
-
This is an issue with vanilla SwiftUI too as the following demonstrates: struct ContentView: View {
@State var isPresented = false
var body: some View {
NavigationStack {
NavigationLink("Drill down") {
Button("Present") {
Task {
try await Task.sleep(nanoseconds: NSEC_PER_SEC * 2)
self.isPresented = true
}
}
.sheet(isPresented: self.$isPresented) {
Text("Hi")
}
}
}
}
} I don't know of a workaround (in TCA or in vanilla SwiftUI) as there doesn't seem to be anyway to be notified if one is in the middle of a drag gesture so that you can cancel any inflight work. I'm going to move this to a discussion since this is not an issue with the library. |
Beta Was this translation helpful? Give feedback.
-
Yeah, I assumed this was an issue with vanilla SwiftUI. I suppose a workaround to prevent this would be to disable the swipe-back gesture during the loading state. I am still pretty new to TCA, so for anyone facing this issue, this StackOverflow answer might be a good starting point. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Description
As I was experimenting with the SwiftUI dismissal swipe gesture (the gesture where you swipe from left to right when going back to a screen), I found that the case study "03-Navigation-Sheet-LoadThenPresent" freezes when the popup triggers. I initially found this bug on the
protocol
branch, but I am able to consistently reproduce this on the most recentmain
branch.The error in the console in the event of the screen freezing prints out:
2022-09-23 17:15:35.976082-0400 SwiftUICaseStudies[2428:123121] [Presentation] Presenting view controller <_TtGC7SwiftUI29PresentationHostingControllerVS_7AnyView_: 0x13160fb70> from detached view controller <_TtGC7SwiftUI19UIHostingControllerGVS_15ModifiedContentVS_7AnyViewVS_24NavigationColumnModifier__: 0x131609a00> is discouraged.
Checklist
main
branch of this package.Expected behavior
The dismissal gesture cancels and the screen behind the popup returns to its initial state. It could also continue the gesture, where the user would navigate to the previous screen, but the popup would dismiss.
Actual behavior
You keep control of the navigation gesture but with the popup sheet still, on top of that page. You can let go when the page is near the right side of the screen, resulting in a dismissal of that page and keeping the popup on your screen. You can also let go when the page is near the left, resulting in the screen freezing indefinitely.
Steps to reproduce
Untitled.mp4
The Composable Architecture version information
0.40.2
Destination operating system
iOS 15.5
Xcode version information
Version 14.0 (14A309)
Swift Compiler version information
Beta Was this translation helpful? Give feedback.
All reactions