Missing tab bar after switching tabs when tab bar is hidden in initial tab

Hi, I'm experiencing the behaviour outlined below. When I navigate programmatically on iPadOS or macOS from a tab that hides the tab bar to another tab, the tab bar remains hidden. The real app has it's entry point in UIKit (i.e. it uses an UITabBarController instead of a SwiftUI TabView) but since the problem is reproducible with a SwiftUI only app, I used one for the sake of simplicity.

import SwiftUI

@main
struct HiddenTabBarTestApp: App {
    @State private var selectedIndex = 0
    
    var body: some Scene {
        WindowGroup {
            TabView(selection: $selectedIndex) {
                Text("First Tab")
                    .tabItem {
                        Label("1", systemImage: "1.circle")
                    }
                    .tag(0)
                
                NavigationStack {
                    Button("Go to first tab") {
                        selectedIndex = 0
                    }
                    .searchable(text: .constant(""))
                }
                .tabItem {
                    Label("2", systemImage: "2.circle")
                }
                .tag(1)
            }
        }
    }
}

Reproduction:

  1. Create a new SwiftUI App with the iOS App template and use the code from above
  2. Run the app on iPadOS or macOS
  3. Navigate to the second tab
  4. Click into the search bar
  5. Click the "Go to first tab" button
  6. The tab bar is no longer visible

Is this a bug in the Framework or is it the expected behaviour? If it's the expected behaviour, do you have a good solution/workaround that doesn't require me to end the search programmatically (e.g. by using @Environment(\.dismissSearch)) before navigating to another tab? The goal would be to show the tab bar in the first tab while keeping the search open in the second tab.

Unfortunately it seems as I can't edit my original post. Here are some more details:

  • I use Xcode 16.2
  • Tested with iPadOS 18.2 and macOS 15.3.1
  • Here is a video demonstrating the issue: https://drive.google.com/file/d/1hosaY5UhSI2m6MU0R_otZm0Vf5tcuXto/view?usp=drive_link
Missing tab bar after switching tabs when tab bar is hidden in initial tab
 
 
Q