Post

Replies

Boosts

Views

Activity

SwiftUI Hierarchical List on macOS represents incorrect results.
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. then, "X" will be replaced by "Y", and "Y" appears twice. 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. 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: 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?
1
1
977
Sep ’22
SwiftUI Hierarchical List on macOS represents incorrect results.
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. then, "X" will be replaced by "Y", and "Y" appears twice. 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. 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: 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?
Replies
1
Boosts
1
Views
977
Activity
Sep ’22