I need to display the following data as a list with groups
However if Item 10 is collapsed Item 11 is shown as Item 02.
What am I doing wrong? Unique IDs are set.
You can see it clearly on screenshots:
Corrupted
https://github.com/kmalyshev/ListProblemExample/blob/main/images/Screenshot1.png
Correct
https://github.com/kmalyshev/ListProblemExample/blob/main/images/Screenshot2.png
The code:
I created a sample project that shows the problem.
https://github.com/kmalyshev/ListProblemExample
I tried it on macOS 11.0.1 and 11.1 Beta
Updated Xcode to 12.3 - same result. OutlineGroup and List with ForEach using recursive view give the same result.
Any help is appreciated.
Code Block - Item 00 - Item 01 - Item 10 - Item 20 - Item 21 - Item 11 - Item 02
However if Item 10 is collapsed Item 11 is shown as Item 02.
What am I doing wrong? Unique IDs are set.
You can see it clearly on screenshots:
Corrupted
https://github.com/kmalyshev/ListProblemExample/blob/main/images/Screenshot1.png
Correct
https://github.com/kmalyshev/ListProblemExample/blob/main/images/Screenshot2.png
The code:
Code Block Swift import SwiftUI struct ContentView: View { let data = Item.getSampleData() var body: some View { List(data, id: \.id, children: \.children) { item in Text(item.name) }.listStyle(SidebarListStyle()) } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } } struct Item: Codable { let id: UUID let name: String let children: [Item]? init(id: UUID = UUID(), name: String, children: [Item]? = nil) { self.id = id self.name = name self.children = children } static func getSampleData() -> [Item] { [ Item(name: "Item 00"), Item( name: "Item 01", children: [ Item( name: "Item 10", children: [ Item(name: "Item 20"), Item(name: "Item 21"), ] ), Item(name: "Item 11"), ] ), Item(name: "Item 02"), ] } }
I created a sample project that shows the problem.
https://github.com/kmalyshev/ListProblemExample
I tried it on macOS 11.0.1 and 11.1 Beta
Updated Xcode to 12.3 - same result. OutlineGroup and List with ForEach using recursive view give the same result.
Any help is appreciated.