[Problem/Question]
I am using the GroupChannelFragment with the default GroupChannelInput (I have not provided a custom Input prop). My screen has a custom ChatHeader component and a custom viewToggleContainer component stacked vertically above the fragment.
On Android, when I tap the text input, the keyboard opens and completely covers the GroupChannelInput. It is not being pushed up at all.
I am measuring the heights of my custom components and passing them to the keyboardAvoidOffset prop, but it seems to have no effect on Android. Here are my debug logs from the Android device:
LOG [ChatScreen] Safe area insets: {“left”:0,“bottom”:16,“right”:0,“top”:37.66666793823242}
LOG [ChatScreen] Header height: 95.33333587646484
LOG [ChatScreen] Toggle height: 77.66666412353516
LOG [ChatScreen] Status bar height: 37.66666793823242
LOG [ChatScreen] Effective keyboard avoid offset passed to GroupChannelFragment: 0
LOG [ChatScreen] Platform: android
My GroupChannelFragment is wrapped in a <View style={{ flex: 1 }}> as recommended.
The main issue is that even when I pass the correct offset for my headers (headerHeight + toggleHeight, which is 173px), the input is still hidden. It seems keyboardAvoidOffset is not being respected on Android when using the default input.
[UIKit Version]
sendbird/uikit-react-native: 3.11.2
[Reproduction Steps]
- Create a screen with a vertical
Viewlayout. - Add a custom
ChatHeadercomponent with a dynamic height (measured viaonLayout). - Add a custom
viewToggleContainercomponent below it with a dynamic height (measured viaonLayout). - Add the
GroupChannelFragmentbelow the toggle, inside a<View style={{ flex: 1 }}>. - Use
createGroupChannelFragmentwithout a customInputprop to use the defaultGroupChannelInput. - Calculate the offset:
const keyboardOffset = headerHeight + toggleHeight;
7.Pass thisoffsetto the fragment:<GroupChannelFragment keyboardAvoidOffset={keyboardOffset} ... />
8.Run on an Android device or emulator. - Tap the
GroupChannelInputat the bottom. - Observe: The keyboard opens and completely covers the input field.
// This is my calculated offset
const keyboardOffset = headerHeight + toggleHeight;
// This is my layout structure
return (
{/* 1. Custom Header */}
<View onLayout={...}>
<ChatHeader ... />
</View>
{/* 2. Custom Toggle */}
<View onLayout={...}>
{/* ...toggle buttons... */}
</View>
{/* 3. Content Area */}
{activeView === 'Chat' ? (
<View style={{ flex: 1 }}>
<GroupChannelFragment
channel={channel!}
keyboardAvoidOffset={keyboardOffset} // <-- This is being passed
// ... other props
/>
</View>
) : (
renderProfileView()
)}
</View>
);