I use a confirmationDialog on a view I present within a sheet. When I press the cancel button, it closes first, then re-appears for about a second and then closes as expected finally.
When I replace this very confirmationDialog with an Alert (by just exchanging the keywords) everything works as expected.
@State private var item: ItemDTO?
@State private var showDeletionConfirmation = false
...
ItemListView(
items: viewModel.items,
editAction: { editItem in
item = editItem
}
)
.sheet(item: $item) { editItem in
ItemView(
item: editItem,
deleteAction: { showDeletionConfirmation = true }
)
.confirmationDialog(
"Sure?",
isPresented: $showDeletionConfirmation,
actions: {
Button("Yes", role: .destructive) {
print("Deleting...")
item = nil
}
Button("Cancel", role: .cancel) {
showDeletionConfirmation = false
}
},
message: {
Text("Do you want to continue?")
}
)