In SwiftUI, there is this bug where a bottom view will not follow the interactive dismissal of the keyboard.

Using this package, we can solve this problem and achieve the expected behavior.

First, you need to add this package to your project dependencies. Then, you can import the package and use the .keyboardAccessory
modifier on any type of scrolling view.
import SwiftUI
import KeyboardAccessory // Import the package
struct ContentView: View {
var body: some View {
VStack {
ChatView()
.keyboardAccessory {
InputView() // The view you want to use as an accessory
}
.scrollDismissesKeyboard(.interactively) // Dismiss the keyboard interactively
}
}
}
There is also a background
closure that lets you add a background view.
ScrollView {}
.keyboardAccessory {
// Accessory
} background {
Rectangle()
.fill(.regularMaterial)
}
This package was built using BottomInputBarSwiftUI, which is used under the MIT license as per the user's permission. I only made some changes to the modifier and created a package. All credit for the actual implementation goes to frogcjn.