Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const EditInput = forwardRef<RNTextInput, EditInputProps>(function EditInput(
autoFocus,
mentionedUsers,
inputDisabled,
partialTextInputProps,
},
ref,
) {
Expand Down Expand Up @@ -70,6 +71,7 @@ const EditInput = forwardRef<RNTextInput, EditInputProps>(function EditInput(
<View style={styles.editInputContainer}>
<View style={styles.inputWrapper}>
<TextInput
{...partialTextInputProps}
ref={ref}
multiline
disableFullscreenUI
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { forwardRef } from 'react';
import {
NativeSyntheticEvent,
Platform,
TextInput as RNTextInput,
TextInputSelectionChangeEventData,
TouchableOpacity,
Expand Down Expand Up @@ -54,6 +55,7 @@ const SendInput = forwardRef<RNTextInput, SendInputProps>(function SendInput(
messageToReply,
setMessageToReply,
messageForThread,
partialTextInputProps,
},
ref,
) {
Expand Down Expand Up @@ -116,7 +118,19 @@ const SendInput = forwardRef<RNTextInput, SendInputProps>(function SendInput(
...messageReplyParams,
}).catch(onFailureToSend);

onChangeText('');
// On iOS with autoCorrect enabled, calling onChangeText('') immediately after sending
// can be ignored due to the keyboard's autocorrect not being committed yet.
// Delay the clear call slightly to allow the autocorrected text to be applied first.
if (Platform.OS === 'ios') {
const textInputRef = ref as React.MutableRefObject<RNTextInput | undefined>;
if (textInputRef.current) {
setTimeout(() => {
onChangeText('');
}, 10);
}
} else {
onChangeText('');
}
setMessageToReply?.();
};

Expand Down Expand Up @@ -186,6 +200,7 @@ const SendInput = forwardRef<RNTextInput, SendInputProps>(function SendInput(
<View style={styles.sendInputContainer}>
{AttachmentsButton && <AttachmentsButton onPress={() => openSheet({ sheetItems })} disabled={inputDisabled} />}
<TextInput
{...partialTextInputProps}
ref={ref}
multiline
disableFullscreenUI
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
import React, { useEffect, useMemo, useState } from 'react';
import { KeyboardAvoidingView, Platform, StyleProp, StyleSheet, TextInput, TextStyle, View } from 'react-native';
import {
KeyboardAvoidingView,
Platform,
StyleProp,
StyleSheet,
TextInput,
TextInputProps,
TextStyle,
View,
} from 'react-native';

import { createStyleSheet, useUIKitTheme } from '@sendbird/uikit-react-native-foundation';
import {
Expand Down Expand Up @@ -79,6 +88,9 @@ export type ChannelInputProps = {
AttachmentsButton?: (props: AttachmentsButtonProps) => React.ReactNode | null;
MessageToReplyPreview?: (props: MessageToReplyPreviewProps) => React.ReactNode | null;
VoiceMessageInput?: (props: VoiceMessageInputProps) => React.ReactNode | null;

// TextInput props - only safe properties that don't interfere with UIKit functionality
partialTextInputProps?: Partial<Pick<TextInputProps, 'autoCorrect'>>;
};

const AUTO_FOCUS = Platform.select({ ios: false, android: true, default: false });
Expand Down
5 changes: 4 additions & 1 deletion packages/uikit-react-native/src/domain/groupChannel/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ export interface GroupChannelProps {

searchItem?: GroupChannelProps['MessageList']['searchItem'];

partialTextInputProps?: GroupChannelProps['Input']['partialTextInputProps'];

/**
* @description You can specify the query parameters for the message list.
* @example
Expand Down Expand Up @@ -111,7 +113,8 @@ export interface GroupChannelProps {
| 'onPressUpdateUserMessage'
| 'onPressUpdateFileMessage'
| 'SuggestedMentionList'
| 'AttachmentsButton',
| 'AttachmentsButton'
| 'partialTextInputProps',
'inputDisabled'
>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const createGroupChannelFragment = (initModule?: Partial<GroupChannelModule>): G
flatListComponent,
flatListProps,
messageListQueryParams,
partialTextInputProps,
collectionCreator,
}) => {
const { playerService, recorderService } = usePlatformService();
Expand Down Expand Up @@ -341,6 +342,7 @@ const createGroupChannelFragment = (initModule?: Partial<GroupChannelModule>): G
onPressSendFileMessage={onPressSendFileMessage}
onPressUpdateUserMessage={onPressUpdateUserMessage}
onPressUpdateFileMessage={onPressUpdateFileMessage}
partialTextInputProps={partialTextInputProps}
/>
</StatusComposition>
</GroupChannelModule.Provider>
Expand Down