Hello, I have a question about FocusState, navigationLink and sheet, the code which in navigationLink closure doesn’t work, but work without navigationLink, just like the following code
struct ContentView: View {
var body: some View {
NavigationStack {
// this work
interView()
// this doesn't work
NavigationLink {
interView()
} label: {
Text("into interView")
}
}
}
}
struct interView: View {
@FocusState var focusStateA : Int?
@State var show : Bool = false
@State var text: String = ""
var body: some View {
ScrollView {
VStack {
coreView
Button("Detail") {
show.toggle()
}
}
.sheet(isPresented: $show, content: {
coreView
})
}
}
}
extension interView {
var coreView : some View {
VStack {
VStack {
putdown
TextField("hi", text: $text)
.focused($focusStateA , equals: 1)
}
}
}
var putdown : some View {
Button(action: {
if focusStateA != nil {
focusStateA = nil
print("OK")
} else {
print("It's nil")
}
}, label: {
Text("Put down the keyboard")
})
}
}
and there are some strange phenomena, I must put all view into a scrollview, otherwise, it even doesn’t work without navigationLink
This problem has existed in IOS 18, and now in IOS26 still doesn’t be settled, is it a problem or some character?