Skip to content

Commit

Permalink
Minor ReportActionComposer code clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
ginsuma committed Jul 10, 2023
1 parent 6a7c1b2 commit 0ea9a5b
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions src/pages/home/report/ReportActionCompose.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,14 +238,6 @@ class ReportActionCompose extends React.Component {
this.focus(false);
});

// This listener is used for focusing the composer again after going back to a report without remounting it.
this.unsubscribeNavFocus = this.props.navigation.addListener('focus', () => {
if (!this.willBlurTextInputOnTapOutside || this.props.isFocused || this.props.modal.isVisible) {
return;
}
this.focus();
});

this.updateComment(this.comment);

// Shows Popover Menu on Workspace Chat at first sign-in
Expand All @@ -262,10 +254,10 @@ class ReportActionCompose extends React.Component {
}

componentDidUpdate(prevProps) {
// We want to focus or refocus the input when a modal has been closed and the underlying screen is focused.
// We want to focus or refocus the input when a modal has been closed or the underlying screen is refocused.
// We avoid doing this on native platforms since the software keyboard popping
// open creates a jarring and broken UX.
if (this.willBlurTextInputOnTapOutside && this.props.isFocused && prevProps.modal.isVisible && !this.props.modal.isVisible) {
if (this.willBlurTextInputOnTapOutside && !this.props.modal.isVisible && this.props.isFocused && (prevProps.modal.isVisible || !prevProps.isFocused)) {
this.focus();
}

Expand All @@ -284,10 +276,6 @@ class ReportActionCompose extends React.Component {

componentWillUnmount() {
ReportActionComposeFocusManager.clear();
if (!this.unsubscribeNavFocus) {
return;
}
this.unsubscribeNavFocus();
}

onSelectionChange(e) {
Expand Down

0 comments on commit 0ea9a5b

Please sign in to comment.