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

[$500] mWeb - Request money - Composer doesn't get focused when coming back with back button from receipt page #28139

Closed
1 of 6 tasks
izarutskaya opened this issue Sep 25, 2023 · 25 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors

Comments

@izarutskaya
Copy link

izarutskaya commented Sep 25, 2023

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Action Performed:

  1. Request money via Scan option
  2. Tap the report preview
  3. Tap the request preview
  4. Tap the receipt image
  5. Click on the back button at the top left corner of the app
  6. Tap on the receipt image again
  7. Click on the system/browser back button

Expected Result:

Composer should be focused on both scenarios (i.e on step 5 and on step 7)

Actual Result:

Composer gets focused when going back through the app back button but doesn't get focused when going back using the system/browser back button

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android / native
  • Android / Chrome
  • iOS / native
  • iOS / Safari
  • MacOS / Chrome / Safari
  • MacOS / Desktop

Version Number: v1.3.74-0

Reproducible in staging?: Y

Reproducible in production?: Y

If this was caught during regression testing, add the test name, ID and link from TestRail:

Email or phone of affected tester (no customers):

Logs: https://stackoverflow.com/c/expensify/questions/4856

Notes/Photos/Videos: Any additional supporting documentation

Screen_Recording_20230920_130434_Chrome.mp4
Screen_Recording_20230925_165641_Chrome.mp4

Expensify/Expensify Issue URL:

Issue reported by: @Nathan-Mulugeta

Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1695204465763599

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~011f26b03f915d1334
  • Upwork Job ID: 1706308727983955968
  • Last Price Increase: 2023-10-16
@izarutskaya izarutskaya added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Sep 25, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 25, 2023

Triggered auto assignment to @JmillsExpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@melvin-bot
Copy link

melvin-bot bot commented Sep 25, 2023

Bug0 Triage Checklist (Main S/O)

  • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
  • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
    • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
  • This bug is reproducible using the reproduction steps in the OP. S/O
    • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
    • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
  • This issue is filled out as thoroughly and clearly as possible
    • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
  • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync

@izarutskaya izarutskaya added the External Added to denote the issue can be worked on by a contributor label Sep 25, 2023
@melvin-bot melvin-bot bot changed the title mWeb - Request money - Composer doesn't get focused when coming back with back button from receipt page [$500] mWeb - Request money - Composer doesn't get focused when coming back with back button from receipt page Sep 25, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 25, 2023

Job added to Upwork: https://www.upwork.com/jobs/~011f26b03f915d1334

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Sep 25, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 25, 2023

Current assignee @JmillsExpensify is eligible for the External assigner, not assigning anyone new.

@melvin-bot
Copy link

melvin-bot bot commented Sep 25, 2023

Triggered auto assignment to Contributor-plus team member for initial proposal review - @ntdiary (External)

@ikevin127
Copy link
Contributor

ikevin127 commented Sep 25, 2023

Proposal

Please re-state the problem that we are trying to solve in this issue

Composer gets focused when going back through the app back button but doesn't get focused when going back using the system/browser back button.

What is the root cause of that problem?

The cause of the problem is the default popstate behaviour of the browser when using the back button, which causes the modal to unmount without animation and prevents the input autofocus from being triggered.

What changes do you think we should make in order to solve the problem?

First of, within the AttachementModal.js component I added a useEffect that detects popstate event and if the modal is open it makes the modal close properly with animation:

     // Listens to popstate event (browser back button) and closes the modal if open
    useEffect(() => {
        window.onpopstate = function (e) {
            if (!e) {
                return;
            }

            if (!isModalOpen) {
                return;
            }

            closeModal();
        }

        // Clean up the event listener
        return () => {
            window.onpopstate = null;
        };
    }, [isModalOpen, closeModal]);

Second, within the ReportActionCompose.js component I added a useEffect that listens to the focus event of the navigation (when modal closes) and if the composer input is NOT focused, using setTimeout o skip the blur function triggered by the modal close event, I focus the composer input like so:

    // We listen to the focus event of the navigator after modal closes and if the composer input is not focused we focus it
    useEffect(() => {
        const unsubscribeNavigationFocus = navigation.addListener('focus', () => {
            if (isFocused) {
                return;
            }

            // using a timeout in order to skip the blur function triggered by the closing of the modal
            setTimeout(() => {
                composerRef.current.focus();
            }, CONST.ANIMATED_TRANSITION);
        });

        // Clean up the event listener
        return () => {
            unsubscribeNavigationFocus();
        };
    }, [isFocused, navigation]);

What alternative solutions did you explore? (Optional)

N/A

Videos:

web.mp4
desktop.mp4
ios.mp4
android.mp4

@melvin-bot
Copy link

melvin-bot bot commented Sep 25, 2023

📣 @ikevin127! 📣
Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:

  1. Make sure you've read and understood the contributing guidelines.
  2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
    Screen Shot 2022-11-16 at 4 42 54 PM
    Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

@ikevin127
Copy link
Contributor

Contributor details
Your Expensify account email: kevin.bader96@gmail.com
Upwork Profile Link: https://www.upwork.com/freelancers/~01f1399768ebd4eaac

@melvin-bot
Copy link

melvin-bot bot commented Sep 25, 2023

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

@melvin-bot melvin-bot bot added the Overdue label Sep 28, 2023
@ntdiary
Copy link
Contributor

ntdiary commented Sep 28, 2023

Hi @ikevin127, thank you for your proposal. : )
Personally, I think the expected behavior in the OP may not be what we really want.
It would be better to add this issue into issue #15992.

cc @JmillsExpensify

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Sep 28, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 2, 2023

@JmillsExpensify, @ntdiary Whoops! This issue is 2 days overdue. Let's get this updated quick!

@melvin-bot
Copy link

melvin-bot bot commented Oct 2, 2023

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@melvin-bot
Copy link

melvin-bot bot commented Oct 4, 2023

@JmillsExpensify, @ntdiary Eep! 4 days overdue now. Issues have feelings too...

@melvin-bot
Copy link

melvin-bot bot commented Oct 6, 2023

@JmillsExpensify, @ntdiary Still overdue 6 days?! Let's take care of this!

@melvin-bot
Copy link

melvin-bot bot commented Oct 9, 2023

@JmillsExpensify @ntdiary this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

@melvin-bot
Copy link

melvin-bot bot commented Oct 9, 2023

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@melvin-bot
Copy link

melvin-bot bot commented Oct 10, 2023

@JmillsExpensify, @ntdiary 10 days overdue. I'm getting more depressed than Marvin.

@JmillsExpensify
Copy link

I agree with @ntdiary, though as you can see in that linked issue, this isn't a priority for us at the moment.

@melvin-bot melvin-bot bot removed the Overdue label Oct 10, 2023
@JmillsExpensify
Copy link

As a result, I've added it to that issue and I think we can still open this issue up for proposals. That is what similarly linked issues are also doing.

@JmillsExpensify
Copy link

Actually wait a second.

@JmillsExpensify
Copy link

Composer should be focused on both scenarios (i.e on step 5 and on step 7)

This is actually not what we want, because we specially only want focus when in a request once you've tapped on the chat input. For all other cases, we actively don't want focus in the chat input. That gets in the way of the data.

@melvin-bot melvin-bot bot added the Overdue label Oct 13, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 16, 2023

@JmillsExpensify @ntdiary this issue is now 3 weeks old. There is one more week left before this issue breaks WAQ and will need to go internal. What needs to happen to get a PR in review this week? Please create a thread in #expensify-open-source to discuss. Thanks!

@melvin-bot
Copy link

melvin-bot bot commented Oct 16, 2023

@JmillsExpensify, @ntdiary Eep! 4 days overdue now. Issues have feelings too...

@melvin-bot
Copy link

melvin-bot bot commented Oct 16, 2023

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@JmillsExpensify
Copy link

Given that we don't want the composer focused by design on the request details screen, I'm going to close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors
Projects
None yet
Development

No branches or pull requests

4 participants