When displaying a popover that contains a TextField, selecting the TextField and presenting the keyboard shrinks the popover. When the popover shrinks, it pushes the TextField out of frame where it can't be seen.
I've tried various ways of sprinkling .ignoresSafeArea(.keyboard) throughout which doesn't help. Also, I've tried making focus explicit with FocusState for the TextField.
Below is an example and screenshots are attached showing how it looks.
import Foundation
import SwiftUI
struct PopoverLab: View {
@State private var showPopover: Bool = false
var body: some View {
Form {
Button("Show Popover", action: { showPopover = true })
.popover(isPresented: $showPopover) {
PopoverForm()
.frame(width: 200, height: 300)
.ignoresSafeArea(.keyboard)
}
}
}
}
private struct PopoverForm: View {
@State private var text: String = ""
@FocusState private var isTextFocused: Bool
var body: some View {
Form {
TextField("Text", text: $text)
.focused($isTextFocused)
}
.ignoresSafeArea(.keyboard)
}
}
Is there a way to make a popover more resilient to the keyboard presenting?