FB7367473: SwiftUI's `.onMove()` stops working if a view has a double-click tap action on macOS
- Date: 2019-10-11
- Resolution: Open
- Area: SwiftUI Framework
- OS: macOS 10.15
- Type: Incorrect/Unexpected Behavior
Description
I have a list of rows that can be reordered with dragging, but I also want to add the ability to double-click a row to edit it. The problem is that when I add .onTapGesture(count: 2) {} to a row, the row can no longer be dragged and dropped.
I have attached an Xcode project that clearly illustrates the problem, I'm also including the code inline here as it's not much:
import SwiftUI
// 1. "Build & run" and then drag a row and notice the blue line indicating support for drag and drop.
struct ContentView: View {
var body: some View {
List {
ForEach(0...5, id: \.self) { index in
Text("Hello World \(index)")
.frame(maxWidth: .infinity, maxHeight: .infinity)
// 2. Uncomment this, "build & run", and notice how there's no longer a blue line indicator when you try to drag a row.
// .onTapGesture(count: 2) {}
}
.onMove { (indexSet, index) in }
}
}
}
Files
even single tap is not working
Encounter the same situation. Have you found out any solution?
Encounter the same situation. Have you found out any solution?
This answer stack overflow is an effective workaround.
And at last, I implement a customized View that wrapped an NSTableView, replace the List.
you have to use .tag(). 2024 And still a problem...