[UIKit] TextField goes up to the top when user taps the textfield

SendBird UIKit version: 2.1.4

I have an issue where user taps the textfield and then the text field moves to the top of the view, making the user unable to see the previous chat nor his/her message.

Link to Video:

The view is implemented in SwiftUI and the structure is like below:

struct ChatView: View {
    var body: some View {
        VStack {
            CustomNavBar()
            SendbirdChannelView(channelUrl: url)
        }
    }
}

struct SendbirdChannelView: UIViewControllerRepresentable {

    func makeUIViewController(context: Context) -> SBUChannelViewController {

        return SBUChannelViewController(channelUrl: channelUrl)

    }

    func updateUIViewController( _ uiViewController: SBUChannelViewController, context: Context) {

    }

    typealias UIViewControllerType = SBUChannelViewController

    let channelUrl: String
}

First, I thought it may be the problem of the navigation bar, but the issue persists after I removed it.
Link to Video:

Ideally, the textField should move upwards when the user taps it but it should stick to the mobile keyboard so that user can see the chat record while typing, like Facebook chat.

Is this a known issue and how should I solve it?

Hi @peter2456

This is happening since the UIKit SDK includes the safe area sizes as well to calculate the position of views.
You can add .ignoresSafeArea() to the SBUChannelViewController to ignore the safe area from the SwiftUI, at least edges: .bottom, so the SDK can show the correct layout.

SendbirdChannelView(
    channelUrl: CHANNEL_URL
).ignoresSafeArea()
2 Likes