.itemProvider in OutlineGroup is not working on macOS

  • OutlineGroup in List: Not Work
  • Hierarchical List: Not Work
  • Pure List: Work

Is it a bug or SwiftUI doesn't support it yet?

Should I use cocoa OutlineView for this feature?

Reproduce:

Copy and Paste code below, and drag items.

import SwiftUI
import PlaygroundSupport

var greeting = "Hello, playground"

struct FileItem: Hashable, Identifiable {
    var id: Self { self }
    var name: String
    var children: [FileItem]? = nil
}

let data = FileItem(name: "users", children:
  [FileItem(name: "user1234", children:
    [FileItem(name: "Photos", children:
      [FileItem(name: "photo001.jpg"),
       FileItem(name: "photo002.jpg")]),
     FileItem(name: "Movies", children:
         [FileItem(name: "movie001.mp4")]),
          FileItem(name: "Documents", children: [])]),
     FileItem(name: "newuser", children:
       [FileItem(name: "Documents", children: [])])])

struct ContentView: View {
    var body: some View {
        VStack {
            Text("Not Work - OutlineGroup in List")
            List {
                OutlineGroup(data, children: \.children) { item in
                    Text("\(item.name)")
                        .itemProvider { NSItemProvider(object: item.name as NSString) }
                }
            }

            Text("Not Work - Hierarchical List")
            List {
                OutlineGroup(data, children: \.children) { item in
                    Text("\(item.name)")
                        .itemProvider { NSItemProvider(object: item.name as NSString) }
                }
            }

            Text("Work - Pure List")
            List([
                FileItem(name: "Documents", children: []),
                FileItem(name: "Files", children: [])
            ]) { item in
                Text("\(item.name)")
                    .itemProvider { NSItemProvider(object: item.name as NSString) }
            }
        }
        .frame(width: 320, height: 800)
    }
}

PlaygroundPage.current.setLiveView(ContentView())
.itemProvider in OutlineGroup is not working on macOS
 
 
Q