sth wrong with .searchable

I add searchable to my SwiftUI List
But the search TextField isn't showing
Here's my code

NavigationView {
    List(searchResults, id: \.self) { item in
        NavigationLink {
            LegendDetailView(item: item)
        } label: {
            HStack {
                Text(item.name).padding(1)
                Spacer()
                Image(systemName: "chevron.right").imageScale(.small)
            }
        }
    }
}.searchable(text: $searchText)

If you drag down the List, then searchBar will show. By default, the search bar is hidden under the navigation title and visible only when a user pulls down the content. Which is a bit confusing.

Start scrolling:

To change the behaviour, replace

.searchable(text: $searchText)

by

.searchable(text: $searchText, placement: .navigationBarDrawer(displayMode: .always))

Default mode is .automatic

Credit: https://sarunw.com/posts/always-show-search-bar-in-swiftui/

pulling down wont work

Surprising, I tested, it worked. You have to drag the list down (that's what the screenshot tried to illustrate). Did you read the sarunw post ? Did you see the SwiftUI animation ?

Is it a MacOS app (you didn't tell).

Use is quite different on MacOS: https://developer.apple.com/documentation/swiftui/view/searchable(text:placement:)

sth wrong with .searchable
 
 
Q