Skip to content

Commit 969f61c

Browse files
committed
fix: usage of text input
1 parent 110c677 commit 969f61c

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

package/src/components/AutoCompleteInput/AutoCompleteInput.tsx

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ type AutoCompleteInputPropsWithContext = TextInputProps &
3636
* that would happen if we put this in the MessageInputContext
3737
*/
3838
cooldownActive?: boolean;
39-
TextInputComponent?: React.ComponentType<TextInputProps>;
39+
TextInputComponent?: React.ComponentType<
40+
TextInputProps & {
41+
ref: React.Ref<RNTextInput> | undefined;
42+
}
43+
>;
4044
};
4145

4246
type AutoCompleteInputProps = Partial<AutoCompleteInputPropsWithContext>;
@@ -53,7 +57,14 @@ const configStateSelector = (state: MessageComposerConfig) => ({
5357
const MAX_NUMBER_OF_LINES = 5;
5458

5559
const AutoCompleteInputWithContext = (props: AutoCompleteInputPropsWithContext) => {
56-
const { channel, cooldownActive = false, setInputBoxRef, t, TextInputComponent, ...rest } = props;
60+
const {
61+
channel,
62+
cooldownActive = false,
63+
setInputBoxRef,
64+
t,
65+
TextInputComponent = RNTextInput,
66+
...rest
67+
} = props;
5768
const [localText, setLocalText] = useState('');
5869
const [textHeight, setTextHeight] = useState(0);
5970
const messageComposer = useMessageComposer();
@@ -114,12 +125,8 @@ const AutoCompleteInputWithContext = (props: AutoCompleteInputPropsWithContext)
114125
[],
115126
);
116127

117-
if (TextInputComponent) {
118-
return <TextInputComponent {...rest} />;
119-
}
120-
121128
return (
122-
<RNTextInput
129+
<TextInputComponent
123130
autoFocus={!!command}
124131
editable={enabled}
125132
maxLength={maxMessageLength}

package/src/components/MessageInput/MessageInput.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useCallback, useEffect, useMemo, useState } from 'react';
2-
import { Modal, SafeAreaView, StyleSheet, TextInputProps, View } from 'react-native';
2+
import { Modal, SafeAreaView, StyleSheet, TextInput, TextInputProps, View } from 'react-native';
33

44
import {
55
Gesture,
@@ -153,7 +153,11 @@ type MessageInputPropsWithContext = Pick<
153153
Pick<TranslationContextValue, 't'> &
154154
Pick<MessageComposerAPIContextValue, 'clearEditingState'> & {
155155
editing: boolean;
156-
TextInputComponent?: React.ComponentType<TextInputProps>;
156+
TextInputComponent?: React.ComponentType<
157+
TextInputProps & {
158+
ref: React.Ref<TextInput> | undefined;
159+
}
160+
>;
157161
};
158162

159163
const textComposerStateSelector = (state: TextComposerState) => ({

0 commit comments

Comments
 (0)