Hi everyone,
I'm having a hard time solving my issue. I have a VStack with a ForEach loop that displays (Core)data info. In that ForEach loop I have a View that has a tap gesture (to open a sheet to edit the entity) and a contextMenu (to allow users to delete the selected entity). The sheet is at the VStack (parent of ForEach) level.
VStack() {
ForEach(customModels) { customModel in
VStack() {
Text(customModel.title)
}
.frame(minWidth: 0, maxWidth: .infinity)
.onTapGesture(perform: {
selectedCustomModel = customModel
})
.contextMenu {
Button {
customViewModel.deleteModel(customModel)
} label: {
Label("Delete", systemImage: "trash")
}
}
}
}
.sheet(item: $selectedCustomModel) { selectedCustomModel in
EditCustomView(customModel: selectedCustomModel)
}
If I long press on one of my "child" view the contextMenu appears, if I dismiss that contextMenu by tapping on another child view, then it triggers the "onTapGesture" (which seems fair), and a warning pops in the console :
Attempt to present <_TtGC7SwiftUI29PresentationHostingControllerVS_7AnyView_: 0x7f90939e05b0> on [...] which is already presenting <_UIContextMenuActionsOnlyViewController: 0x7f9093983bd0>.
The problem is at that point any tap on a child view does not work, the onTapGesture is like "dead" I have to tap like 5 or 10 times to to make the edit sheet appears...
Is this a bug or do you see something bad in my implementation ?
Thank you
Jim