It works for me on very simple views like this, where the button brings the TextEditor into focus as expected.
struct ContentView: View {
@State var tempField: String = ""
@State var isShowingSheet: Bool = false
@FocusState var isFocused: Bool
var body: some View {
VStack {
TextEditor(text: $tempField)
.padding()
.focused($isFocused)
Button(action: {isFocused = true})
{
Text("Focus!")
}
}
}
}
Put them both in a sheet however, and it doesn't work anymore.
struct ContentView: View {
@State var tempField: String = ""
@State var isShowingSheet: Bool = false
@FocusState var isFocused: Bool
var body: some View {
VStack {
Button(action: {self.isShowingSheet = true}) {
Text("Sheet!")
}.sheet(isPresented: $isShowingSheet) {
TextEditor(text: $tempField)
.padding()
.focused($isFocused)
Button(action: {isFocused = true})
{
Text("Focus!")
}
}
}
}
}
I've also submitted feedback FB9166651.