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

Focus the composer again after going back from a report not found #21962

Merged
merged 3 commits into from
Jul 4, 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
12 changes: 12 additions & 0 deletions src/pages/home/report/ReportActionCompose.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,14 @@ 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();
Copy link
Contributor

@Julesssss Julesssss Jul 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit of a random guess, but I'm seeing a new crash associated and I'm curious if:

  • It's possible this change is the cause
  • Or maybe this exception simply occurred during testing? (do you have a Pixel 5 by any chance?)
Non-fatal Exception: io.invertase.firebase.crashlytics.JavaScriptError: Cannot read property 'focus' of null
       at .anonymous(address at index.android.bundle:1:2694129)
       at .apply((native):0:0)
       at .anonymous(address at index.android.bundle:1:237083)
       at ._callTimer(address at index.android.bundle:1:236365)
       at .callTimers(address at index.android.bundle:1:238167)
       at .apply((native):0:0)
       at .__callFunction(address at index.android.bundle:1:140250)
       at .anonymous(address at index.android.bundle:1:138615)
       at .__guard(address at index.android.bundle:1:139568)
       at .callFunctionReturnFlushedQueue(address at index.android.bundle:1:138573)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

@ginsuma ginsuma Jul 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can I reprocedue it? Or source map?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is pretty strange - because we have all needed conditions to not get situation when this.textinput will null and we will try to focus

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I could be wrong here. This was just the only loc that contained a focus() call since yesterdays build.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can I reprocedue it? Or source map?

I'm afraid we can't. That's why this is a bit of a random guess. If we don't think this was the cause then no further action is necessary 👍

});

this.updateComment(this.comment);

// Shows Popover Menu on Workspace Chat at first sign-in
Expand Down Expand Up @@ -274,6 +282,10 @@ class ReportActionCompose extends React.Component {

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

onSelectionChange(e) {
Expand Down