How to prevent wheel Picker conflict with DragGesture in SwiftUI

Issue #836

If we have a Picker inside a View that has DragGesture, chances are when we scroll the wheel, the DragGesture is detected too

To prevent this, we can attach a dummy DragGesture to our Picker

Picker("", selection: $number) {
    ForEach(FavoriteNumbers.allCases) { number in
        Text(number.name)
    }
}
.pickerStyle(WheelPickerStyle())
.gesture(DragGesture())
Written by

I’m open source contributor, writer, speaker and product maker.

Start the conversation