From 08dd70b33dc1cbd6247f17f4af25bac46c568a19 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Thu, 20 Jul 2023 00:46:21 +0800 Subject: [PATCH 1/2] setup the compose focus manager on screen focus --- src/pages/home/report/ReportActionCompose.js | 28 ++++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/pages/home/report/ReportActionCompose.js b/src/pages/home/report/ReportActionCompose.js index 8155f09b2aac..ee33f3699956 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); @@ -299,6 +293,18 @@ class ReportActionCompose extends React.Component { this.unsubscribeNavigationFocus(); } + 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); + }); + } + onSelectionChange(e) { LayoutAnimation.configureNext(LayoutAnimation.create(50, LayoutAnimation.Types.easeInEaseOut, LayoutAnimation.Properties.opacity)); this.setState({selection: e.nativeEvent.selection}); From c7e737a7a2b3c20c3f9674003b113fa6e7850fbc Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Thu, 20 Jul 2023 01:03:15 +0800 Subject: [PATCH 2/2] fix lint --- src/pages/home/report/ReportActionCompose.js | 24 ++++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/pages/home/report/ReportActionCompose.js b/src/pages/home/report/ReportActionCompose.js index ee33f3699956..0cca6227a0d1 100644 --- a/src/pages/home/report/ReportActionCompose.js +++ b/src/pages/home/report/ReportActionCompose.js @@ -293,18 +293,6 @@ class ReportActionCompose extends React.Component { this.unsubscribeNavigationFocus(); } - 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); - }); - } - onSelectionChange(e) { LayoutAnimation.configureNext(LayoutAnimation.create(50, LayoutAnimation.Types.easeInEaseOut, LayoutAnimation.Properties.opacity)); this.setState({selection: e.nativeEvent.selection}); @@ -318,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: [],