@SceneStorage on iPad potrait doesn't show the correct screen

Overview

  • On the iPad Portrait mode using @SceneStorage doesn't show the detail screen, instead it shows the place holder screen.
  • Tapping on the back button then shows the restored detail screen

Steps to Reproduce

  1. Run on iPad potrait
  2. Select the Car "bbb"
  3. See the Car Detail with the car name "bbb"
  4. Enter background
  5. Repeat steps 1 and 2

Actual Behaviour:

Notice the car name is not displayed, it shows the "No car selected" text, tapping on the back button then shows the CarDetail screen with the name "bbb"

Expected Behaviour: 

The shows the CarDetail screen should show with the name "bbb" immediately instead of showing the place holder screen

Note:

  • It works fine on iPhone potrait and iPad landscape
  • Problem is on iPad potrait and iPhone 13 Pro max landscape

Code:

ContentView

struct ContentView: View {

    var body: some View {
        NavigationView {
            CarList()
            Text("No car selected")
                .font(.largeTitle)
        }
    }
}

CarList

struct CarList: View {
    
    let cars = [Car(id: 1, name: "aaa"),
                Car(id: 2, name: "bbb"),
                Car(id: 3, name: "ccc")]
    
    @SceneStorage("selectedCarID") private var selectedCarID: Int?
    
    var body: some View {
        List {
            ForEach(cars) { car in
                NavigationLink(tag: car.id, selection: $selectedCarID) {
                    CarDetail(name: car.name)
                } label: {
                    Text(car.name)
                }
            }
        }
    }
}

CarDetail

struct CarDetail: View {
    let name: String
    var body: some View {
        ZStack {
            Color.brown
            Text(name)
                .font(.largeTitle)
        }
    }
}

Car

struct Car: Identifiable {
    var id: Int
    var name: String
}

GIF

@SceneStorage on iPad potrait doesn't show the correct screen
 
 
Q