Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor ReportActionComposer code clean up #22550

Merged
merged 1 commit into from
Jul 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading