Programmatically expand a list in SwiftUI 2

Hi there,

I have a question regarding the new expandable lists in SwiftUI 2. When I create a sidebar with an expandable list its collapsed by default.
Is there any way to either programmatically expand certain items via a binding or to store the expansions so that the app will remember which items where expanded after the app is opened again?

Here is my code:

Code Block language
struct SidebarMenu2: Identifiable {
    let id: String
    let title: String
    let icon: String?
    let action: (() -> Void)?
    var menues: [SidebarMenu2]?
    init(title: String, icon: String? = nil, action: @escaping () -> Void) {
        self.id = title
        self.title = title
        self.icon = icon
        self.action = action
        self.menues = nil
    }
    init(title: String, icon: String? = nil, menues: [SidebarMenu2]?) {
        self.id = title
        self.title = title
        self.icon = icon
        self.action = nil
        self.menues = menues
    }
}
struct Sidebar2: View {
    var menu: [SidebarMenu2] { [
        SidebarMenu2(
            title: "My Library",
            menues: [
                SidebarMenu2(title: "Profiles", icon: "person.fill") {
                    print("Profiles")
                },
                SidebarMenu2(title: "Categories", icon: "tray.full.fill") {
                    print("Profiles2")
                },
            ]
        )]
    }
    var body: some View {
        VStack(alignment: .leading) {
            List(menu, children: \.menues) { menu in
                Label(menu.title, systemImage: menu.icon!)
            }
        }
    }
}


Programmatically expand a list in SwiftUI 2
 
 
Q