Focus automatically on searchable

Viewed 656

I am using the new searchable modifier: https://developer.apple.com/documentation/swiftui/form/searchable(text:placement:). When a user enters the view with a that modifier, that text field is not automatically focussed.

Is there a way to get focus on the searchable? This is my view, it is called with NavigationLink

import SwiftUI

struct UserFindView: View {
    @State private var searchText = ""

    var body: some View {
        Text("Please search")
                .searchable(text: $searchText)
                .navigationTitle("Title")
                .navigationBarTitleDisplayMode(.inline)
    }
}
0 Answers
Related