Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions packages/uikit-react-native/src/components/ChannelInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,12 @@ export type ChannelInputProps = {
};

const AUTO_FOCUS = Platform.select({ ios: false, android: true, default: false });
const KEYBOARD_AVOID_VIEW_BEHAVIOR = Platform.select({ ios: 'padding' as const, default: undefined });
const isAndroidApi35 = Platform.OS === 'android' && Platform.Version >= 35;
const KEYBOARD_AVOID_VIEW_BEHAVIOR = Platform.select({
ios: 'padding' as const,
android: isAndroidApi35 ? ('padding' as const) : undefined,
default: undefined,
});

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

const safeArea = useSafeAreaPadding(['top', 'left', 'right', 'bottom']);

// Android API 35+ keyboard avoidance handling
const keyboardVerticalOffset = isAndroidApi35 ? keyboardAvoidOffset : -safeArea.paddingBottom + keyboardAvoidOffset;
const { colors, typography } = useUIKitTheme();
const { sbOptions, mentionManager } = useSendbirdChat();

Expand Down Expand Up @@ -138,10 +146,7 @@ const ChannelInput = (props: ChannelInputProps) => {

return (
<>
<KeyboardAvoidingView
keyboardVerticalOffset={-safeArea.paddingBottom + keyboardAvoidOffset}
behavior={KEYBOARD_AVOID_VIEW_BEHAVIOR}
>
<KeyboardAvoidingView keyboardVerticalOffset={keyboardVerticalOffset} behavior={KEYBOARD_AVOID_VIEW_BEHAVIOR}>
<View
style={{
paddingStart: safeArea.paddingStart,
Expand Down Expand Up @@ -181,7 +186,7 @@ const ChannelInput = (props: ChannelInputProps) => {
/>
)}
</View>
<SafeAreaBottom height={safeArea.paddingBottom} />
{!isAndroidApi35 && <SafeAreaBottom height={safeArea.paddingBottom} />}
</View>
</KeyboardAvoidingView>
{mentionAvailable && props.SuggestedMentionList && (
Expand Down