Hello,
I have an issue with the automatic keyboard dismissing in a modal : If I present a modal with textfields, and I try to dismiss the modal to close the keyboard, the keyboard disappear (that's good) but it leave some space...
Here is the example :
And here is my code to reproduce the issue (iOS 16, real device) :
struct ContentView: View {
@State private var isViewPresented: Bool = false
var body: some View {
Button {
isViewPresented = true
} label: {
Text("Show View")
}
.sheet(isPresented: $isViewPresented) {
FormView()
}
}
}
struct FormView: View {
var body: some View {
NavigationView {
ScrollView {
VStack(spacing: 32) {
TextField("Text 1", text: .constant(""))
.frame(height: 42)
.background(Color.red)
TextField("Text 2", text: .constant(""))
.frame(height: 42)
.background(Color.red)
TextField("Text 3", text: .constant(""))
.frame(height: 42)
.background(Color.red)
TextField("Text 4", text: .constant(""))
.frame(height: 42)
.background(Color.red)
}
}
.background(Color.yellow)
.navigationTitle("Form view")
}
}
}
As you can see, when I start to dismiss the modal, the keyboard disappear and then there is a black space who appears...
Any suggestions ?
Thanks,
Alexandre