A item is replaced by the last uncle.
Conditions are:
Target to macOS
The item "X" is placed next to the folded sibling with children.
The parent of the "X" is not the last sibling.
The last uncle "Y" has no children.
It's amazing that the very fundamental operations are broken.
As this issue only occurs on macOS, it is not reproduced on playground preview or iOS.
Code Block swift import SwiftUI struct TreeViewTest: View { var items: [Item] var body: some View { List( items, children: \.children ) { item in Text(item.id) } } struct Item: Hashable, Identifiable { var id: String var children: [Self]? } } struct TreeViewTest_Previews: PreviewProvider { static var previews: some View { TreeViewTest(items: [ .init(id: "0", children: [ .init(id: "00"), .init(id: "01", children: [ .init(id: "010"), .init(id: "011"), .init(id: "012") ]), .init(id: "02"), .init(id: "03") ]), .init(id: "1") ]) } }
It represents:
Code Block plain -0 --00 -+01 --1 /* <- should be 02 */ --03 -1
Is there anything wrong with my code?
If it is a bug, is there a temporary hacky workaround?