Page MenuHomePhabricator

D14011.id46027.diff
No OneTemporary

D14011.id46027.diff

diff --git a/native/chat/chat-input-bar.react.js b/native/chat/chat-input-bar.react.js
--- a/native/chat/chat-input-bar.react.js
+++ b/native/chat/chat-input-bar.react.js
@@ -337,13 +337,16 @@
+expandButtons: () => void,
+hideButtons: () => void,
+immediatelyHideButtons: () => void,
+ +textInputRef: { current: ?React.ElementRef<typeof TextInput> },
+ +clearableTextInputRef: { current: ?ClearableTextInput },
+ +selectableTextInputRef: {
+ current: ?React.ElementRef<typeof SelectableTextInput>,
+ },
+ +setTextInputRef: (ref: ?React.ElementRef<typeof TextInput>) => void,
+ +setClearableTextInputRef: (ref: ?ClearableTextInput) => void,
};
class ChatInputBar extends React.PureComponent<Props> {
- textInput: ?React.ElementRef<typeof TextInput>;
- clearableTextInput: ?ClearableTextInput;
- selectableTextInput: ?React.ElementRef<typeof SelectableTextInput>;
-
clearBeforeRemoveListener: () => void;
clearFocusListener: () => void;
clearBlurListener: () => void;
@@ -494,7 +497,7 @@
if (Platform.OS !== 'ios') {
return;
}
- const { textInput } = this;
+ const textInput = this.props.textInputRef.current;
if (!textInput) {
return;
}
@@ -603,7 +606,7 @@
const keyboardInputHost =
Platform.OS === 'android' ? null : (
- <KeyboardInputHost textInputRef={this.textInput} />
+ <KeyboardInputHost textInputRef={this.props.textInputRef.current} />
);
let editedMessage;
@@ -722,9 +725,9 @@
placeholderTextColor={this.props.colors.listInputButton}
multiline={true}
style={this.props.styles.textInput}
- textInputRef={this.textInputRef}
- clearableTextInputRef={this.clearableTextInputRef}
- ref={this.selectableTextInputRef}
+ textInputRef={this.props.setTextInputRef}
+ clearableTextInputRef={this.props.setClearableTextInputRef}
+ ref={this.props.selectableTextInputRef}
selectionColor={`#${this.props.threadInfo.color}`}
/>
<AnimatedView style={this.props.sendButtonContainerStyle}>
@@ -747,20 +750,6 @@
);
}
- textInputRef = (textInput: ?React.ElementRef<typeof TextInput>) => {
- this.textInput = textInput;
- };
-
- clearableTextInputRef = (clearableTextInput: ?ClearableTextInput) => {
- this.clearableTextInput = clearableTextInput;
- };
-
- selectableTextInputRef = (
- selectableTextInput: ?React.ElementRef<typeof SelectableTextInput>,
- ) => {
- this.selectableTextInput = selectableTextInput;
- };
-
updateText = (text: string) => {
if (this.props.isExitingDuringEditModeRef.current) {
return;
@@ -787,7 +776,10 @@
}, 400);
focusAndUpdateTextAndSelection = (text: string, selection: Selection) => {
- this.selectableTextInput?.prepareForSelectionMutation(text, selection);
+ this.props.selectableTextInputRef.current?.prepareForSelectionMutation(
+ text,
+ selection,
+ );
this.props.setText(text);
this.props.setTextEdited(true);
this.props.setSelectionState({ text, selection });
@@ -810,7 +802,8 @@
};
focusAndUpdateButtonsVisibility = () => {
- const { textInput } = this;
+ const textInput = this.props.textInputRef.current;
+
if (!textInput) {
return;
}
@@ -833,7 +826,7 @@
this.props.updateSendButton('');
- const { clearableTextInput } = this;
+ const clearableTextInput = this.props.clearableTextInputRef.current;
invariant(
clearableTextInput,
'clearableTextInput should be sent in onSend',
@@ -1399,6 +1392,23 @@
setButtonsExpanded(false);
}, [expandoButtonsOpen, targetExpandoButtonsOpen]);
+ const textInputRef = React.useRef<?React.ElementRef<typeof TextInput>>();
+ const clearableTextInputRef = React.useRef<?ClearableTextInput>();
+ const selectableTextInputRef =
+ React.useRef<?React.ElementRef<typeof SelectableTextInput>>();
+ const setTextInputRef = React.useCallback(
+ (ref: ?React.ElementRef<typeof TextInput>) => {
+ textInputRef.current = ref;
+ },
+ [],
+ );
+ const setClearableTextInputRef = React.useCallback(
+ (ref: ?ClearableTextInput) => {
+ clearableTextInputRef.current = ref;
+ },
+ [],
+ );
+
return (
<ChatInputBar
{...props}
@@ -1451,6 +1461,11 @@
expandButtons={expandButtons}
hideButtons={hideButtons}
immediatelyHideButtons={immediatelyHideButtons}
+ textInputRef={textInputRef}
+ clearableTextInputRef={clearableTextInputRef}
+ selectableTextInputRef={selectableTextInputRef}
+ setTextInputRef={setTextInputRef}
+ setClearableTextInputRef={setClearableTextInputRef}
/>
);
}

File Metadata

Mime Type
text/plain
Expires
Wed, Nov 27, 2:24 AM (15 h, 45 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2587289
Default Alt Text
D14011.id46027.diff (4 KB)

Event Timeline