0

In SwiftUI, I have a .searchable searchbar with a TabView in the .page style as the content. When the user taps the cancel button, the searchbar disappears.

import SwiftUI

struct ContentView: View {
    @State var searchText = ""
    
    var body: some View {
        NavigationView {
            TabView {
                Text("Tab Content")
            }
            .tabViewStyle(.page)
        }
        .searchable(text: $searchText)
    }
}

That's what happens:

TabView Searchable Bug

Removing the .tabViewStyle(.page) fix the problem (but then I cannot use the .page style of TabView):

TabView Searchable expected behavior

Am I doing something wrong? Or is this a SwiftUI bug?

Dan Flict
  • 117
  • 8

0 Answers0