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 @@ -308,12 +308,13 @@ +navigation: ?ChatNavigationProp<'MessageList'>, +overlayContext: ?OverlayContextType, +messageEditingContext: ?MessageEditingContextType, + +selectionState: SyncedSelectionData, + +setSelectionState: (data: SyncedSelectionData) => void, }; type State = { +text: string, +textEdited: boolean, +buttonsExpanded: boolean, - +selectionState: SyncedSelectionData, +isExitingDuringEditMode: boolean, }; class ChatInputBar extends React.PureComponent { @@ -342,7 +343,6 @@ text: props.draft, textEdited: false, buttonsExpanded: true, - selectionState: { text: props.draft, selection: { start: 0, end: 0 } }, isExitingDuringEditMode: false, }; @@ -671,8 +671,8 @@ } const typeaheadRegexMatches = getTypeaheadRegexMatches( - this.state.selectionState.text, - this.state.selectionState.selection, + this.props.selectionState.text, + this.props.selectionState.selection, nativeMentionTypeaheadRegex, ); @@ -861,8 +861,8 @@ allowImagePasteForThreadID={this.props.threadInfo.id} value={this.state.text} onChangeText={this.updateText} - selection={this.state.selectionState.selection} - onUpdateSyncedSelectionData={this.updateSelectionState} + selection={this.props.selectionState.selection} + onUpdateSyncedSelectionData={this.props.setSelectionState} placeholder="Send a message..." placeholderTextColor={this.props.colors.listInputButton} multiline={true} @@ -920,10 +920,6 @@ this.saveDraft(text); }; - updateSelectionState: (data: SyncedSelectionData) => void = data => { - this.setState({ selectionState: data }); - }; - saveDraft: (text: string) => void = _throttle(text => { this.props.dispatch({ type: updateDraftActionType, @@ -939,8 +935,8 @@ this.setState({ text, textEdited: true, - selectionState: { text, selection }, }); + this.props.setSelectionState({ text, selection }); this.saveDraft(text); this.focusAndUpdateButtonsVisibility(); @@ -1308,6 +1304,12 @@ ); const editMessage = useEditMessage(); + const [selectionState, setSelectionState] = + React.useState({ + text: draft, + selection: { start: 0, end: 0 }, + }); + return ( ); }