Skip to content

Commit a7618af

Browse files
authored
Merge pull request #252 from sendbird/fix/support-android-15-keyboard-avoid
[CLNP-7469] fix: improve keyboard avoidance behavior for Android API 35+
2 parents 9cf3c39 + 4e640f0 commit a7618af

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

packages/uikit-react-native/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
"@openspacelabs/react-native-zoomable-view": "^2.1.5",
6363
"@sendbird/uikit-chat-hooks": "3.10.0",
6464
"@sendbird/uikit-react-native-foundation": "3.10.0",
65-
"@sendbird/uikit-tools": "0.0.10",
65+
"@sendbird/uikit-tools": "0.0.15",
6666
"@sendbird/uikit-utils": "3.10.0"
6767
},
6868
"devDependencies": {

packages/uikit-react-native/src/components/ChannelInput/index.tsx

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,12 @@ export type ChannelInputProps = {
8282
};
8383

8484
const AUTO_FOCUS = Platform.select({ ios: false, android: true, default: false });
85-
const KEYBOARD_AVOID_VIEW_BEHAVIOR = Platform.select({ ios: 'padding' as const, default: undefined });
85+
const isAndroidApi35 = Platform.OS === 'android' && Platform.Version >= 35;
86+
const KEYBOARD_AVOID_VIEW_BEHAVIOR = Platform.select({
87+
ios: 'padding' as const,
88+
android: isAndroidApi35 ? ('padding' as const) : undefined,
89+
default: undefined,
90+
});
8691

8792
// FIXME(iOS): Dynamic style does not work properly when typing the CJK. (https://github.com/facebook/react-native/issues/26107)
8893
// To workaround temporarily, change the key for re-mount the component.
@@ -96,6 +101,15 @@ const ChannelInput = (props: ChannelInputProps) => {
96101
const { channel, keyboardAvoidOffset, messageToEdit, setMessageToEdit } = props;
97102

98103
const safeArea = useSafeAreaPadding(['top', 'left', 'right', 'bottom']);
104+
105+
// Android API 35+ keyboard avoidance handling
106+
/**
107+
* Android API 35+ introduced edge-to-edge layouts, which changed how keyboard avoidance should be handled.
108+
* For API 35+, the system manages insets automatically, so we use the provided keyboardAvoidOffset directly.
109+
* For older Android versions, we manually subtract the safe area bottom padding to avoid overlapping with system UI.
110+
* See: https://developer.android.com/develop/ui/views/layout/edge-to-edge
111+
*/
112+
const keyboardVerticalOffset = isAndroidApi35 ? keyboardAvoidOffset : -safeArea.paddingBottom + keyboardAvoidOffset;
99113
const { colors, typography } = useUIKitTheme();
100114
const { sbOptions, mentionManager } = useSendbirdChat();
101115

@@ -138,10 +152,7 @@ const ChannelInput = (props: ChannelInputProps) => {
138152

139153
return (
140154
<>
141-
<KeyboardAvoidingView
142-
keyboardVerticalOffset={-safeArea.paddingBottom + keyboardAvoidOffset}
143-
behavior={KEYBOARD_AVOID_VIEW_BEHAVIOR}
144-
>
155+
<KeyboardAvoidingView keyboardVerticalOffset={keyboardVerticalOffset} behavior={KEYBOARD_AVOID_VIEW_BEHAVIOR}>
145156
<View
146157
style={{
147158
paddingStart: safeArea.paddingStart,
@@ -181,7 +192,7 @@ const ChannelInput = (props: ChannelInputProps) => {
181192
/>
182193
)}
183194
</View>
184-
<SafeAreaBottom height={safeArea.paddingBottom} />
195+
{!isAndroidApi35 && <SafeAreaBottom height={safeArea.paddingBottom} />}
185196
</View>
186197
</KeyboardAvoidingView>
187198
{mentionAvailable && props.SuggestedMentionList && (

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3721,10 +3721,10 @@
37213721
resolved "https://registry.yarnpkg.com/@sendbird/chat/-/chat-4.19.2.tgz#a60346e6aaaa0d65697cfc46d619bdebb7c01999"
37223722
integrity sha512-scytefM8c9Ja+fm3oWkFHAZt7TqV2Q5EDbCJFtFmRvyRa+TYUjtHmSKpvrGZEyjjU/oBTK/JohZ1Zb2AixUANg==
37233723

3724-
"@sendbird/[email protected].10":
3725-
version "0.0.10"
3726-
resolved "https://registry.yarnpkg.com/@sendbird/uikit-tools/-/uikit-tools-0.0.10.tgz#b522339426e0a6f859047ac1e4c1bf695f6dbef9"
3727-
integrity sha512-HRc7vLo2XASpbL0QtUR2r5py1pcy+1xTgIqUWxsJp8/ih+YbnrLMNz6hJgAwBEtpw5+d1fhY+ZzvWdRihQX5ew==
3724+
"@sendbird/[email protected].15":
3725+
version "0.0.15"
3726+
resolved "https://registry.yarnpkg.com/@sendbird/uikit-tools/-/uikit-tools-0.0.15.tgz#86a1ac41fdf1624b984bd8f875d1091ac5842afa"
3727+
integrity sha512-VJukrtFwcqk5u4QYk0qva8ntJupvYCyNYjdNUWawjxYd9UbmODIld2TBkDBjiNtlVfK6UlzfKdvCVCJ30hC7pQ==
37283728

37293729
"@sideway/address@^4.1.5":
37303730
version "4.1.5"

0 commit comments

Comments
 (0)