Skip to content

Commit b696e3b

Browse files
authored
Merge pull request #255 from sendbird/feat/supprot-for-text-input-props
[CLNP-7474] feat: supprot-for-text-input-props
2 parents 76d3f67 + 68d5be2 commit b696e3b

File tree

5 files changed

+37
-3
lines changed

5 files changed

+37
-3
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const EditInput = forwardRef<RNTextInput, EditInputProps>(function EditInput(
3131
autoFocus,
3232
mentionedUsers,
3333
inputDisabled,
34+
partialTextInputProps,
3435
},
3536
ref,
3637
) {
@@ -70,6 +71,7 @@ const EditInput = forwardRef<RNTextInput, EditInputProps>(function EditInput(
7071
<View style={styles.editInputContainer}>
7172
<View style={styles.inputWrapper}>
7273
<TextInput
74+
{...partialTextInputProps}
7375
ref={ref}
7476
multiline
7577
disableFullscreenUI

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, { forwardRef } from 'react';
22
import {
33
NativeSyntheticEvent,
4+
Platform,
45
TextInput as RNTextInput,
56
TextInputSelectionChangeEventData,
67
TouchableOpacity,
@@ -54,6 +55,7 @@ const SendInput = forwardRef<RNTextInput, SendInputProps>(function SendInput(
5455
messageToReply,
5556
setMessageToReply,
5657
messageForThread,
58+
partialTextInputProps,
5759
},
5860
ref,
5961
) {
@@ -116,7 +118,19 @@ const SendInput = forwardRef<RNTextInput, SendInputProps>(function SendInput(
116118
...messageReplyParams,
117119
}).catch(onFailureToSend);
118120

119-
onChangeText('');
121+
// On iOS with autoCorrect enabled, calling onChangeText('') immediately after sending
122+
// can be ignored due to the keyboard's autocorrect not being committed yet.
123+
// Delay the clear call slightly to allow the autocorrected text to be applied first.
124+
if (Platform.OS === 'ios') {
125+
const textInputRef = ref as React.MutableRefObject<RNTextInput | undefined>;
126+
if (textInputRef.current) {
127+
setTimeout(() => {
128+
onChangeText('');
129+
}, 10);
130+
}
131+
} else {
132+
onChangeText('');
133+
}
120134
setMessageToReply?.();
121135
};
122136

@@ -186,6 +200,7 @@ const SendInput = forwardRef<RNTextInput, SendInputProps>(function SendInput(
186200
<View style={styles.sendInputContainer}>
187201
{AttachmentsButton && <AttachmentsButton onPress={() => openSheet({ sheetItems })} disabled={inputDisabled} />}
188202
<TextInput
203+
{...partialTextInputProps}
189204
ref={ref}
190205
multiline
191206
disableFullscreenUI

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
import React, { useEffect, useMemo, useState } from 'react';
2-
import { KeyboardAvoidingView, Platform, StyleProp, StyleSheet, TextInput, TextStyle, View } from 'react-native';
2+
import {
3+
KeyboardAvoidingView,
4+
Platform,
5+
StyleProp,
6+
StyleSheet,
7+
TextInput,
8+
TextInputProps,
9+
TextStyle,
10+
View,
11+
} from 'react-native';
312

413
import { createStyleSheet, useUIKitTheme } from '@sendbird/uikit-react-native-foundation';
514
import {
@@ -79,6 +88,9 @@ export type ChannelInputProps = {
7988
AttachmentsButton?: (props: AttachmentsButtonProps) => React.ReactNode | null;
8089
MessageToReplyPreview?: (props: MessageToReplyPreviewProps) => React.ReactNode | null;
8190
VoiceMessageInput?: (props: VoiceMessageInputProps) => React.ReactNode | null;
91+
92+
// TextInput props - only safe properties that don't interfere with UIKit functionality
93+
partialTextInputProps?: Partial<Pick<TextInputProps, 'autoCorrect'>>;
8294
};
8395

8496
const AUTO_FOCUS = Platform.select({ ios: false, android: true, default: false });

packages/uikit-react-native/src/domain/groupChannel/types.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ export interface GroupChannelProps {
5353

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

56+
partialTextInputProps?: GroupChannelProps['Input']['partialTextInputProps'];
57+
5658
/**
5759
* @description You can specify the query parameters for the message list.
5860
* @example
@@ -111,7 +113,8 @@ export interface GroupChannelProps {
111113
| 'onPressUpdateUserMessage'
112114
| 'onPressUpdateFileMessage'
113115
| 'SuggestedMentionList'
114-
| 'AttachmentsButton',
116+
| 'AttachmentsButton'
117+
| 'partialTextInputProps',
115118
'inputDisabled'
116119
>;
117120

packages/uikit-react-native/src/fragments/createGroupChannelFragment.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ const createGroupChannelFragment = (initModule?: Partial<GroupChannelModule>): G
7070
flatListComponent,
7171
flatListProps,
7272
messageListQueryParams,
73+
partialTextInputProps,
7374
collectionCreator,
7475
}) => {
7576
const { playerService, recorderService } = usePlatformService();
@@ -341,6 +342,7 @@ const createGroupChannelFragment = (initModule?: Partial<GroupChannelModule>): G
341342
onPressSendFileMessage={onPressSendFileMessage}
342343
onPressUpdateUserMessage={onPressUpdateUserMessage}
343344
onPressUpdateFileMessage={onPressUpdateFileMessage}
345+
partialTextInputProps={partialTextInputProps}
344346
/>
345347
</StatusComposition>
346348
</GroupChannelModule.Provider>

0 commit comments

Comments
 (0)