Preserve selection state between Tab Bar and Sidebar during size class transition?

I'm trying to replicate the behavior of Apple's own Music and Photos apps where the main navigation is displayed as a Tab Bar when horizontally compact but as a sidebar in a split view when not compact.

I've found sample code (including the Fruita demo) that demonstrates using Tab Bar or Sidebar depending on size class, but it doesn't preserve the detail view state the way Music and Photos do. For example, in Music if you select "Search" and then begin multitasking the "Search" detail view remains visible and stays selected during the transition from Sidebar to Tab Bar or visa versa.

I suspect this may be easier to do manually in UIKit, but I'm kind of surprised it's not the default behavior in SwiftUI. Has anyone been able to replicate the Sidebar/Tab Bar transition behavior of Photos or Music in SwiftUI?

Preserve selection state between Tab Bar and Sidebar during size class transition?
 
 
Q