Skip to content

Instantly share code, notes, and snippets.

@pd95
Created November 9, 2024 13:46
Show Gist options
  • Save pd95/088dddaa0328113bb545eb396651beee to your computer and use it in GitHub Desktop.
Save pd95/088dddaa0328113bb545eb396651beee to your computer and use it in GitHub Desktop.
Bottom view not moving while interactive keyboard dismissal is ongong
import SwiftUI
struct MessageInput: View {
@State private var text = ""
@FocusState private var isFocused: Bool
var body: some View {
HStack {
TextField("Enter your message…", text: $text)
.textFieldStyle(.roundedBorder)
.padding(.trailing)
.focused($isFocused)
}
.padding(.horizontal)
.padding(.vertical, 8)
}
}
struct ContentView: View {
var colors: [Color] = [.red, .brown, .green, .cyan, .blue, .purple]
var body: some View {
NavigationStack {
ScrollViewReader { scrollView in
VStack(spacing: 0) {
ScrollView {
VStack(spacing: 0) {
ForEach(colors.indices, id: \.self) { colorIndex in
Rectangle()
.fill(colors[colorIndex])
.frame(height: 200)
.id(colorIndex)
}
}
}
.scrollDismissesKeyboard(.interactively) // allow dismissing the keyboard interactively
.navigationTitle("Chat")
.navigationBarTitleDisplayMode(.inline)
.onAppear() {
scrollView.scrollTo(colors.indices.last, anchor: .bottom)
}
MessageInput()
.background(Material.thin)
}
.background(.red)
}
}
}
}
@pd95
Copy link
Author

pd95 commented Aug 6, 2025

This seems to be fixed in iOS 26 - at least in beta 4 (23A5297f)

@raphael1233333
Copy link

This seems to be fixed in iOS 26 - at least in beta 4 (23A5297f)

Nice thanks for info :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment