MacOS SwiftUI List move multiple rows

Hi, I have this simple view in SwiftUI, where it's possible to move a single row and select one or more rows.
Code Block swift
struct ContentView: View {
    @State var selectedItems = Set<Int>()
    @State var items = Array(1...10).map({ S(id: $0) })
    var body: some View {
        List(selection: $selectedItems) {
            ForEach(items) { (item) in
                Text(String(item.id))
                    .padding()
            }
            .onMove(perform: { indices, newOffset in
                withAnimation {
                    self.items.move(fromOffsets: indices, toOffset: newOffset)
                }
            })
        }
    }
}

When I select 2 or more rows and try to move them I got this error log:
Code Block
2020-07-30 10:20:03.035238+0200 list[54240:1678921] [General] There are 2 items on the pasteboard, but 1 drag images. There must be 1 draggingItem per pasteboardItem.
2020-07-30 10:20:03.039250+0200 list[54240:1678921] [General] (
0   CoreFoundation                      0x00007fff2a8865af __exceptionPreprocess + 242
1   libobjc.A.dylib                     0x00007fff6acb36c4 objc_exception_throw + 48
2   CoreFoundation                      0x00007fff2a886413 +[NSException raise:format:] + 189
3   AppKit                              0x00007fff27a61d80 -[NSDraggingSession(NSInternal) _initWithPasteboard:image:offset:source:] + 243
4   AppKit                              0x00007fff27a617ba -[NSCoreDragManager dragImage:fromWindow:at:offset:event:pasteboard:source:slideBack:] + 1767
5   AppKit                              0x00007fff27a610c1 -[NSWindow(NSDrag) dragImage:at:offset:event:pasteboard:source:slideBack:] + 134
6   AppKit                              0x00007fff27ec27fb -[NSTableView _doImageDragUsingRowsWithIndexes:event:pasteboard:source:slideBack:startRow:] + 665
7   AppKit                              0x00007fff27ec2cb2 -[NSTableView _checkOverrideAndDoImageDragUsingRowsWithIndexes:event:pasteboard:source:slideBack:startRow:] + 254
8   AppKit                              0x00007fff27ec3956 -[NSTableView _performClassicDragOfIndexes:hitRow:event:] + 444
9   AppKit                              0x00007fff27a88936 -[NSTableView _performDragFromMouseDown:] + 472
10  AppKit                              0x00007fff27a87fce -[NSTableView mouseDown:] + 5300
11  AppKit                              0x00007fff27935028 -[NSWindow(NSEventRouting) _handleMouseDownEvent:isDelayedEvent:] + 4956
12  AppKit                              0x00007fff278a413c -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 2594
13  AppKit                              0x00007fff278a34fe -[NSWindow(NSEventRouting) sendEvent:] + 347
14  AppKit                              0x00007fff278a18e8 -[NSApplication(NSEvent) sendEvent:] + 352
15  AppKit                              0x00007fff27b78cd6 -[NSApplication _handleEvent:] + 65
16  AppKit                              0x00007fff27709f83 -[NSApplication run] + 623
17  AppKit                              0x00007fff276dde14 NSApplicationMain + 816
18  SwiftUI                             0x00007fff363c8cd4 $s7SwiftUI6runAppys5NeverOSo21NSApplicationDelegate_pFTf4e_nAA07TestingdG0C_Tg5 + 100
19  SwiftUI                             0x00007fff36bf0162 $s7SwiftUI6runAppys5NeverOxAA0D0RzlF + 162
20  SwiftUI                             0x00007fff367b8e9d $s7SwiftUI3AppPAAE4mainyyFZ + 61
21  list                                0x0000000105397f71 $s4list0A3AppV5$mainyyFZ + 33
22  list                                0x0000000105397ff4 main + 20
23  libdyld.dylib                       0x00007fff6bf2d7d1 start + 1
24  ???                                 0x0000000000000003 0x0 + 3
)

Did I do something wrong or it's bug in SwiftUI? Is it possible to move more than 1 row at once?
Thanks a lot!
  • Just to let everybody know who stumble over your example: it does work perfectly fine.

    (I was looking for an example and found yours :-))

Add a Comment

Accepted Reply

apparently this is fixed now and works great.

Replies

apparently this is fixed now and works great.