Adding a drag gesture to a View inside a ScrollView blocks the scrolling

So I have a

ScrollView
holding a set of views:
ScrollView {
     ForEach(setOfData) { data in
          NavigationLink(destination: ...) {
               CustomView(data: data)
          }
          .buttonStyle(BackgroundButtonStyle())
     }
}

In a

CustomView
I have a drag gesture:
let drag = DragGesture()
     .updating($gestureState) { value, gestureState, _ in
          // ...
     }
     .onEnded { value in
          // ...
     }

Which I assign to a part of the view:

ZStack(alignment: .leading) {
     HStack {
          // ...
     }
     HStack {
          // ...
     }
     .gesture(drag)
     // or .simultaneousGesture(drag)
}

As soon as I attach the gesture, the

ScrollView
stop scrolling. The only way to make it scroll it to start scrolling from a part of it which has no gesture attached. How can I avoid it and make them both work together. In UIKit is was as simple as specifying
true
in
shouldRecognizeSimultaneouslyWith
method. How can I have the same in SwiftUI?


In SwiftUI I've tried attaching a gesture using

.simultaneousGesture(drag)
and
.highPriorityGesture(drag)
– they all work the same as
.gesture(drag)
. I've also tried providing all possible static
GestureMask
values for
including:
parameter – I have either scroll working or my drag gesture working. Never both of them.


Adding a

simultaneousGesture
to a
ScrollView
directly make both of them work simultaneously. Even though I'm not sure it's even possible to get the
View
my gesture relates to and manipulate its subviews in this case. And even in this case it makes
ScrollView
behaving weird – it always generates accidental view taps on release when you end scrolling. So in my list you almost can't scroll without triggering a
NavigationLink
.

I am seeing this as well. file a bug report to possibly get their attention.

I am having the same exact issue! The only workaround I've found to work reliably is to add a minimum dragging distance to my gesture.

Code Block
DragGesture(minimumDistance: 20)


Since the minimumDistance for ScrollViews is lower than the DragGesture, the scroll will always have priority. Unfortunately I did not found any way to achieve simultaneous gestures.
Adding a drag gesture to a View inside a ScrollView blocks the scrolling
 
 
Q