Reset the detail view on NavigationSplitView 3-column when a new Sidebar item is selected, but no content item

Is there a way to clear/reset the detail view when the user selects a new item in the sidebar but hasn't yet selected an item from the content panel?

Playing around with the WWDC22 demo project "Navigation Cookbook", I noticed that if you select a Category, then a Recipe, the recipe details display as expected. If you then select a new category, though, the original recipe remains in the detail panel until you select a new recipe. I'd like the detail panel to reset to its original state of "Pick a Recipe".

Remove Selection

Can you set selectedRecipe = nil, that should remove any selection of the recipe.

Selection of recipe is driven by the state variable selectedRecipe so depending on the value different recipes

Reference:

https://developer.apple.com/documentation/swiftui/list

Reset the detail view on NavigationSplitView 3-column when a new Sidebar item is selected, but no content item
 
 
Q