Alexey Kolchedanstev
Alexey Kolchedanstev

Reputation: 122

SwiftUI tap gesture blocks item deleting action in List

So I have a view with List, also this view has side menu. I added tapGesture to my VStack to dismiss side menu when it's open, but then I face issue, tapGesture is blocking onDelete method of List. Any ideas how to fix that??

Here is code example:

VStack {
.....
    List {
          ForEach(){
           //list elements here
          }
          .onDelete {
            // delete action here
          }
    }
}
.onTapGesture {
// action here 
}

Also, if while deleting I swipe once till the end, it's working. But if I swipe just a little and try to press Delete button nothing happens.

Upvotes: 5

Views: 891

Answers (1)

Valentin
Valentin

Reputation: 385

Replace your .onTapGesture with the simultaneousGesture modifier.

.simultaneousGesture(TapGesture().onEnded {
    // action here 
})

Upvotes: 0

Related Questions