I have same issue while using fastlane snapshot. Based on Matt_PeakRidge's answer, here is my workaround. As my app only works with iOS 16 I couldn't use iOS 15.5 simulator. But iOS 16.0 worked so:
Install iOS 16.0 simulator from Xcode
Set deployment target to iOS 16.0 in Test scheme.
In Snapfile file add ios_version("16.0").
Post
Replies
Boosts
Views
Activity
After hours of tries I could find something interesting: if, in the sheet content, I add a button to dismiss the sheet, the bug doesn't appear anymore. But if I dismiss the sheet with finger (drag from top to bottom), it still appears.Here is modified code:
struct ContentView: View {
@State private var isOpen = false
var body: some View {
Button(action: {
isOpen.toggle()
}, label: {
Text("Open sheet")
.foregroundColor(.white)
.padding()
.background(.blue)
})
.sheet(isPresented: $isOpen, content: {
SheetContent()
})
}
}
struct SheetContent: View {
@Environment(\.dismiss) var dismiss
var body: some View {
Button(action: { dismiss() }, label: {
Text("Dismiss sheet")
})
}
}
It looks like there is something with calling (or not) the @Environment(\.dismiss) var dismiss.
The current state is a bit better as few days ago as the bug only appears when user dismiss the sheet by dragging down. But there is still something wrong.
Is there a way to programmatically call dismiss() when sheet is closed by dragging down?
Hi,
I've exactly same behavior and found a pretty good solution :
I assume you have something like this in your tasks view list :
ForEach (selectedProject.tasks) { task in
// Your UI here
}
My solution is to not use selectedProject.tasks on this view but use @FetchRequest to get tasks for selected project. Code is something like :
@ObservedObjectvar selectedProject: Project
@FetchRequest var tasks: FetchedResultsTask
init(withProject project: Project) {
self.selectedProject = project
_tasks = FetchRequest(
entity: Task.entity(),
sortDescriptors: [
NSSortDescriptor(keyPath: \Task.text, ascending: true)
],
predicate: NSPredicate(format: "project == %@", project)
)
}
And change your ForEach by (and any where you were using selectedProject.tasks) :
ForEach (tasks) { Task in
// Your UI here
}
With this solution : Listing works using ForEach
Deleting a Task works also.
When you edit a Task in DetailsView, go back to this list view, it updates list content (it should already work)
But most important : When you edit a Task in DetailsView, go back to list view and go again in DetailsView, it is updated like expected!
I hope it helps you. Best,
Jonathan