tabViewBottomAccessory in 26.1: View's @State is lost when switching tabs

Any view that is content for the tabViewBottomAccessory API fails to retain its state as of the last couple of 26.1 betas (and RC). The loss of state happens (at least) when the currently selected tab is switched (filed as FB20901325).

Here's code to reproduce the issue:

struct ContentView: View {
    @State private var selectedTab = TabSelection.one

    enum TabSelection: Hashable {
        case one, two
    }

    var body: some View {
        TabView(selection: $selectedTab) {
            Tab("One", systemImage: "1.circle", value: .one) {
                BugExplanationView()
            }
            Tab("Two", systemImage: "2.circle", value: .two) {
                BugExplanationView()
            }
        }
        .tabViewBottomAccessory {
            AccessoryView()
        }
    }
}

struct AccessoryView: View {
    @State private var counter = 0 // This guy's state gets lost (as of iOS 26.1)

    var body: some View {
        Stepper("Counter: \(counter)", value: $counter)
            .padding(.horizontal)
    }
}

struct BugExplanationView: View {
    var body: some View {
        ScrollView {
            VStack(alignment: .leading, spacing: 16) {
                Text("(1) Manipulate the counter state")
                Text("(2) Then switch tabs")
                Text("BUG: The counter state gets unexpectedly reset!")
            }
            .multilineTextAlignment(.leading)
        }
    }
}

Thanks for filing this, I'm noticing the same thing today.

Still an issue on iOS 26.3 Beta 1.

FB21364908

Hello j_salling,

Thank you for reporting this issue and for your patience waiting for a response. I have escalated this report to the appropriate teams, and they confirmed it looks like a bug. In the meantime, we recommend moving the @State outside of the bottom accessory view.

 Travis Trotto - DTS Engineer

Simply including an @Environment property in any subview of tabViewBottomAccessory triggers the same identity loss bug, making the use of TabViewBottomAccessoryPlacement and/or ColorScheme challenging.

Submitted as FB21627918, full reproduction in https://developer.apple.com/forums/thread/812723.

iOS 26.3 beta 2 (23D5103d) is also affected.

tabViewBottomAccessory in 26.1: View's @State is lost when switching tabs
 
 
Q