Add the ContentView below to an iPad or multi-platform app, and run it on an iPad or simulator.
- Pinch the onscreen keyboard into the small floating format. In the simulator, long-press the keyboard dismissal button and select "Floating."
- Tap the Search field in the toolbar.
Observe that the keyboard floats over the list, and both lists are entirely in view.
- Now toggle the Split button in the toolbar; this changes the HStack to an HSplit.
Observe that the bottom of the lists are treated as if the keyboard had a full-screen width.
If you uncomment the padding() modifier on line 21, you'll observe that Lists behave badly too. So I suspect this might also be a SwiftUI bug.
import SwiftUI
import SplitView
struct ContentView: View {
@State private var search = ""
@State private var split = false
var body: some View {
NavigationStack {
VStack(spacing: 0) {
if split {
HSplit(left: {ListView(index: 1)}, right: {ListView(index: 2)})
} else {
HStack {
ListView(index: 1)
Divider()
ListView(index: 2)
}
}
} // Commenting out the padding() line makes the HStack behave as expected
// .padding() // but the SplitView still truncates under the floating keyboard.
.searchable(text: $search)
.toolbar {
Button(split ? "No Split" : "Split") {split.toggle()}
}
}
}
}
struct ListView: View {
let index: Int
var body: some View {
VStack(spacing: 0) {
Text("List \(index)")
.font(.title)
List(1...50, id: \.self) {index in
Text("Item \(index)")
}
}
}
}
Add the ContentView below to an iPad or multi-platform app, and run it on an iPad or simulator.
Observe that the keyboard floats over the list, and both lists are entirely in view.
Observe that the bottom of the lists are treated as if the keyboard had a full-screen width.
If you uncomment the padding() modifier on line 21, you'll observe that Lists behave badly too. So I suspect this might also be a SwiftUI bug.