feedback-assistant / reports

Open collection of Apple Feedback Assistant reports
216 stars 2 forks source link

FB7367473: SwiftUI's `.onMove()` stops working if a view has a double-click tap action on macOS #46

Open sindresorhus opened 4 years ago

sindresorhus commented 4 years ago

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

swiftui-onmove-testcase.zip

L1cardo commented 4 years ago

even single tap is not working

funway commented 3 years ago

Encounter the same situation. Have you found out any solution?

funway commented 3 years ago

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.