Replies: 1 comment 3 replies
-
Hi @Myrronth, unfortunately this is just a vanilla SwiftUI bug. Your vanilla example does not capture it because you use This recreation of your demo using Click to expandimport SwiftUI
class Model: ObservableObject {
@Published var showSheet: Bool = false
@Published var showSheet2: Bool = false
@Published var shouldShowSheet2: Bool = false
}
struct ContentView: View {
@Environment(\.scenePhase) var scenePhase
@ObservedObject var model = Model()
var body: some View {
VStack {
Button {
model.showSheet = true
} label: {
Text("Show sheet 1")
}
}
.padding()
.sheet(isPresented: $model.showSheet, onDismiss: {
if model.shouldShowSheet2 {
model.showSheet2 = true
}
}) {
VStack {
Text("Sheet 1")
Button {
model.showSheet = false
model.shouldShowSheet2 = true
} label: {
Text("Show sheet 2")
}
}
}
.sheet(isPresented: $model.showSheet2) {
Text("Sheet 2")
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
} Maybe there is some kind of workaround to get fix the behavior, in TCA or vanilla SwiftUI, but as of right now it does not seem like a bug that the library itself can fix. As such I am going to convert this to a discussion. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Description
As soon as the scenePhase environment variable is used in a view that can open multiple sheets using the same @PresentationState property as source, the second sheet gets dismissed and is immediately opened again when the scenePhase changes (e.g. dragging down/up the Control Center, or when the bluetooth permission system alert is presented).
This does only occur on iOS 15, on iOS 16 it all works as expected.
main
branch as it uses the new navigation toolsExamples
Video that shows the behaviour
https://youtube.com/shorts/Bgx5hEO8CUs
Checklist
main
branch of this package.Expected behavior
The sheet stays open, regardless of the scenePhase changes.
Actual behavior
The sheet gets dismissed and is immediately opened again when the scenePhase changes—but only on iOS 15 (and maybe below, I currently don't have a device/simulator with <iOS 15)
Steps to reproduce
The Composable Architecture version information
f18a72c
Destination operating system
iOS 15
Xcode version information
14.3.1
Swift Compiler version information
Beta Was this translation helpful? Give feedback.
All reactions