Crash with OutlineGroup on macOS

I've got a Multiplatform SwiftUI app and I'm trying to create a hierarchical structure with OutlineGroup. My code works fine on iOS. Tho on macOS I get a crash.

Code Block swift
List {
Section(header: Text("A")) {
OutlineGroup(layers.aLayers,
children: \.children) { layer in
LayerView(layer: layer,
selectedID: $layers.id)
}
}
Section(header: Text("B")) {
OutlineGroup(layers.bLayers,
children: \.children) { layer in
LayerView(layer: layer,
selectedID: $layers.id)
}
}
}
.listStyle(SidebarListStyle())

Does anyone know what this means?

Thread 1: Fatal error: Could not find child #1 for Optional(SwiftUI.OutlineItem(id: SwiftUI.ViewListID.Canonical(_index: 0, implicitID: 0, explicitID: nil), isGroupItem: true))


Replies

OutlineGroup is currently (as of beta6) rather buggy – many actions on simple lists cause crashes like this.

My current work-around (which isn't really a work-around) is to just render a flattened list and indent child elements manually. You don't get the automatic disclosure indicators, but it works OK until the sidebar outline groups get working.