reports
reports copied to clipboard
FB10596836: iOS 16 Beta 3 completely breaks keyboard avoidance and Spacer() frames
- Date: 2022-07-09
- Resolution: Open
- Area: SwiftUI Framework
- OS: iOS 16 Beta 3
- Type: Incorrect/Unexpected Behavior
- Keywords: SwitftUI, iOS
Description
Starting with iOS 16 beta 3 (I believe, I was unable to test beta 2 but it works fine on every iOS version from 14-16 beta 1), keyboard avoidance with Spacer() in a VStack completely breaks when the control center is opened. The correct behaviour should be, Spacer() object above a TextField shrinks when keyboard appears, and the TextField returns to its original position when keyboard is dismissed.
On beta 3, this works fine up until the user opens the control center. At that point, Spacers() no longer resize properly. If the keyboard was open when the control center was opened, when the keyboard is dismissed the TextField is stuck above where the keyboard was. (i.e. the Spacer() has not grown to take all available space again). Similarly, if the control center was opened when the TextField was not in focus, when the TextField gains focus it will not move up above the keyboard (i.e. the Spacer() does not shrink to fit above the keyboard).
The correct behaviour was seen throughout iOS 14-15, and was definitely present on iOS 16 beta 1. I have attached a video of the incorrect behaviour on a real device running iOS 16 beta 3, and a video of the correct behaviour on a simulator running beta 1.
Please list the steps you took to reproduce the issue:
- Have a TextField in a VStack with a Spacer() above the TextField.
- Focus/dismiss the TextField multiple times to observe the Spacer() is resizing as appropriate.
- With the TextField either focused or dismissed, pull down to open the control center, and then dismiss the control center
- Focus/dismiss the TextField and observe that the TextField no longer avoids the keyboard and the Spacer() is not resizing.
The sample code below is the minimal reproduction:
struct ContentView: View {
@State private var text: String = ""
var body: some View {
VStack {
Spacer()
TextField("Enter text:", text: $text)
.border(.gray)
Spacer().frame(height: 16)
}
}
}
Alternatively I have attached a sample project with this code alone.