Incorrect display mode of navigation bar title

Originator:azeffin
Number:rdar://FB9718909 Date Originated:22 October 2021
Status:Open Resolved:
Product:SwiftUI Product Version:
Classification:Incorrect/Unexpected Behavior Reproducible:Yes
 
Summary:
Navigation bar title ignores `navigationBarTitleDisplayMode` when NavigationView shown via `.sheet` and contained in conditional content view.

Steps to reproduce:
1. Create SwiftUI iOS app with following implementation
```
import SwiftUI

@main
struct SheetNavApp: App {
  var body: some Scene {
    WindowGroup {
      ContentView()
    }
  }
}

struct ContentView: View {
  @State var showSheet = false

  var body: some View {
    Button("Show sheet") { showSheet = true }
    .sheet(isPresented: $showSheet) { SheetView() }
  }
}

struct SheetView: View {
  enum ViewState {
    case initial, navigationView
  }
  @State private var state: ViewState = .initial

  @ViewBuilder
  var body: some View {
    switch state {
    case .initial:
      VStack {
        Button("Show navigation") { state = .navigationView }
      }
    case .navigationView:
      NavigationView {
        VStack {
          Text("In navigation")
        }
        .navigationTitle("A title")
        .navigationBarTitleDisplayMode(.inline)
      }
    }
  }
}
```
2. Run app on iOS 15 device
3. Tap on 'Show sheet' button
4. Tap on 'Show navigation' button

Observed behavior:
Navigation bar title displayed in `large` mode.

Expected behavior:
Navigation bar title displayed in `inline` mode

Note:
In iOS 14.5 title displayed correctly.
Also `.navigationBarHidden(true)` modifier does not work in this case as well.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!