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 @@ -315,11 +315,10 @@ +setTextEdited: (edited: boolean) => void, +buttonsExpanded: boolean, +setButtonsExpanded: (expanded: boolean) => void, + +isExitingDuringEditModeRef: { current: boolean }, }; -type State = { - +isExitingDuringEditMode: boolean, -}; -class ChatInputBar extends React.PureComponent { + +class ChatInputBar extends React.PureComponent { textInput: ?React.ElementRef; clearableTextInput: ?ClearableTextInput; selectableTextInput: ?React.ElementRef; @@ -341,10 +340,6 @@ constructor(props: Props) { super(props); - this.state = { - isExitingDuringEditMode: false, - }; - this.setUpActionIconAnimations(); this.setUpSendIconAnimations(); } @@ -880,7 +875,7 @@ }; updateText = (text: string) => { - if (this.state.isExitingDuringEditMode) { + if (this.props.isExitingDuringEditModeRef.current) { return; } this.props.setText(text); @@ -1008,7 +1003,7 @@ removeEditMode: RemoveEditMode = action => { const { navigation } = this.props; - if (!navigation || this.state.isExitingDuringEditMode) { + if (!navigation || this.props.isExitingDuringEditModeRef.current) { return 'ignore_action'; } if (!this.isMessageEdited()) { @@ -1094,7 +1089,7 @@ }; onNavigationFocus = () => { - this.setState({ isExitingDuringEditMode: false }); + this.props.isExitingDuringEditModeRef.current = false; }; onNavigationBlur = () => { @@ -1102,7 +1097,8 @@ return; } this.props.setText(this.props.draft); - this.setState({ isExitingDuringEditMode: true }, this.exitEditMode); + this.props.isExitingDuringEditModeRef.current = true; + this.exitEditMode(); }; onNavigationBeforeRemove = (e: { @@ -1117,12 +1113,8 @@ e.preventDefault(); const saveExit = () => { this.props.messageEditingContext?.setEditedMessage(null, () => { - this.setState({ isExitingDuringEditMode: true }, () => { - if (!this.props.navigation) { - return; - } - this.props.navigation.dispatch(action); - }); + this.props.isExitingDuringEditModeRef.current = true; + this.props.navigation?.dispatch(action); }); }; if (!this.isMessageEdited()) { @@ -1353,6 +1345,8 @@ threadPermissions.JOIN_THREAD, ); + const isExitingDuringEditModeRef = React.useRef(false); + return ( ); }