diff --git a/src/pages/home/report/ReportActionCompose.js b/src/pages/home/report/ReportActionCompose.js index 8155f09b2aac..0cca6227a0d1 100644 --- a/src/pages/home/report/ReportActionCompose.js +++ b/src/pages/home/report/ReportActionCompose.js @@ -241,19 +241,13 @@ class ReportActionCompose extends React.Component { } componentDidMount() { - // This callback is used in the contextMenuActions to manage giving focus back to the compose input. - // TODO: we should clean up this convoluted code and instead move focus management to something like ReportFooter.js or another higher up component - ReportActionComposeFocusManager.onComposerFocus(() => { - if (!this.willBlurTextInputOnTapOutside || !this.props.isFocused) { - return; - } - - this.focus(false); - }); - this.unsubscribeNavigationBlur = this.props.navigation.addListener('blur', () => KeyDownListener.removeKeyDownPressListner(this.focusComposerOnKeyPress)); - this.unsubscribeNavigationFocus = this.props.navigation.addListener('focus', () => KeyDownListener.addKeyDownPressListner(this.focusComposerOnKeyPress)); + this.unsubscribeNavigationFocus = this.props.navigation.addListener('focus', () => { + KeyDownListener.addKeyDownPressListner(this.focusComposerOnKeyPress); + this.setUpComposeFocusManager(); + }); KeyDownListener.addKeyDownPressListner(this.focusComposerOnKeyPress); + this.setUpComposeFocusManager(); this.updateComment(this.comment); @@ -312,6 +306,18 @@ class ReportActionCompose extends React.Component { this.calculateMentionSuggestion(); } + setUpComposeFocusManager() { + // This callback is used in the contextMenuActions to manage giving focus back to the compose input. + // TODO: we should clean up this convoluted code and instead move focus management to something like ReportFooter.js or another higher up component + ReportActionComposeFocusManager.onComposerFocus(() => { + if (!this.willBlurTextInputOnTapOutside || !this.props.isFocused) { + return; + } + + this.focus(false); + }); + } + getDefaultSuggestionsValues() { return { suggestedEmojis: [],