I am creating a Sidebar-style view for an iPad app, using the NavigationLink(destination:tag:selection:label) to control the detail view. Visually, everything appears to be working correctly, however a subtle issue exists when tapping an item to change the selection. The contents of my List are being processed twice, which is observed by putting a breakpoint at the first Text component in the code below - the first time through, my selectedHomeId value is populated correctly (and does load the HomeView correctly), however the second time through, the selectedSignalId is nil.
This does not impact the HomeView, and the app is still usable, however it does clear out the SceneStorage that I'm attempting to configure, and it results in the HomeView not being able to respond to changes in my model.
I've also filed a feedback for this (FB7845359) - if any other developers have experienced this, please file your own as well!
This does not impact the HomeView, and the app is still usable, however it does clear out the SceneStorage that I'm attempting to configure, and it results in the HomeView not being able to respond to changes in my model.
Code Block @SceneStorage("selectedHome") var selectedHomeId:String? var sidebarType = SidebarType.full var body: some View { List { if sidebarType == .full || sidebarType == .homes { Text("Homes") .font(.headline) ForEach(homeStore.homes) { home in NavigationLink(destination: HomeView(home: home), tag: home.id.description, selection: $selectedHomeId) { Label(home.name, systemImage: "house") } } } } .listStyle(SidebarListStyle()) .navigationTitle(sidebarType == .homes ? "Homes" : "Other") .navigationBarItems(trailing: SettingsButtonView()) }
I've also filed a feedback for this (FB7845359) - if any other developers have experienced this, please file your own as well!