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

[C+ Checklist Needs Completion] [$1000] Web - Task title input is not focused after reloading the page #22850

Closed
1 of 6 tasks
kbecciv opened this issue Jul 13, 2023 · 104 comments
Closed
1 of 6 tasks
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering Internal Requires API changes or must be handled by Expensify staff

Comments

@kbecciv
Copy link

kbecciv commented Jul 13, 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. Open the app
  2. Go to assign task from FAB
  3. Reload the page

Expected Result:

Input should remain focused

Actual Result:

Input is not focused after reload

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: 1.3.40-4
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

bandicam.2023-07-13.23-39-23-060.mp4
Recording.3614.mp4

Expensify/Expensify Issue URL:
Issue reported by: @gadhiyamanan
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1689271743989309

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01e4d7c9a31e0cc909
  • Upwork Job ID: 1680028911628701696
  • Last Price Increase: 2023-08-05
@kbecciv kbecciv added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jul 13, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jul 13, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Jul 13, 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

@chiragxarora
Copy link
Contributor

chiragxarora commented Jul 13, 2023

PROPOSAL

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

Task title input is not focused after reloading the page

What is the root cause of that problem?

RCA is that we are focusing it under the onEntryTransitionEnd prop and when we reload the page from modal open, transition never happens and input is never focused

onEntryTransitionEnd={() => inputRef.current && inputRef.current.focus()}

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

Solution 1: use autoFocus prop (with/without shouldDelayFocus)

Solution 2: use a callback ref

We can create a callback ref which will listen to the changes happening in reference to the input field, and whenever our input element is ready, we will focus it

const inputRefCallback = useCallback((el) => {
      if(!el) return;
      if(!inputRef.current) {
          el.focus();
      }
      inputRef.current = el;
  }, [])

What alternative solutions did you explore? (Optional)

None

@bernhardoj
Copy link
Contributor

It's not the problem with onEntryTransitionEnd but rather the problem with how withOnyx works. The input is inside a Form that is wrapped with withOnyx. There is a previous discussion here https://expensify.slack.com/archives/C01GTK53T8Q/p1684263976356599 and looks like the solution (workaround) is to use a timeout.

We have more and more pages that use Form and I personally think onEntryTransitionEnd is a much better solution compared to timeout. So, I guess we should find/agree upon a real solution this time. I think moving the withOnyx higher in the tree (from Form to the Page that uses Form) is the simplest one considering we don't want to change how withOnyx works. There are currently 29 usages of Form.

cc: @s77rt @hayata-suenaga @marcaaron

@chiragxarora
Copy link
Contributor

Thanks for sharing this insightful thread, understood the RCA now

@greg-schroeder
Copy link
Contributor

Hmm - should I mark this External or wait for the outcome of that discussion @bernhardoj? Sounds like we may not know exactly where we want to go with this.

@bernhardoj
Copy link
Contributor

bernhardoj commented Jul 14, 2023

I'm not sure about that too. Maybe I can translate my comment here into a proposal (even though it's technically not my solution haha) then we can apply the External label so we can have more opinions from the assigned engineer and C+?

@gadhiyamanan
Copy link
Contributor

gadhiyamanan commented Jul 14, 2023

@greg-schroeder this is dupe of #20000 we can reopen original issue

@greg-schroeder
Copy link
Contributor

greg-schroeder commented Jul 15, 2023

I'n not going to reopen that issue as this one has a more robust discussion about the issue and proposals already working. I'll list you as the issue reporter, though. Apologies @chiragxarora, this one was a duplicate report.

@greg-schroeder greg-schroeder added the External Added to denote the issue can be worked on by a contributor label Jul 15, 2023
@melvin-bot melvin-bot bot changed the title Web - Task title input is not focused after reloading the page [$1000] Web - Task title input is not focused after reloading the page Jul 15, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jul 15, 2023

Job added to Upwork: https://www.upwork.com/jobs/~01e4d7c9a31e0cc909

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

melvin-bot bot commented Jul 15, 2023

Current assignee @greg-schroeder is eligible for the External assigner, not assigning anyone new.

@melvin-bot
Copy link

melvin-bot bot commented Jul 15, 2023

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

@tienifr
Copy link
Contributor

tienifr commented Jul 15, 2023

Proposal

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

Input is not focused after reload task input page

What is the root cause of that problem?

A. If we access the page via link, sometimes the input is not focused, this is due to the roomNameInput.current might not be initialized yet at the time onEntryTransitionEnd is called. As correctly pointed out by @bernhardoj here, that's how withOnyx works and the input is wrapped in a Form which uses withOnyx, the input will not be rendered until the form data is loaded.

I don't think we should make any changes to how we're using withOnyx, there's no problem with that. The problem is we're incorrectly assuming that the inputRef will be available at the time the onEntryTransitionEnd is called, as can be seen here.

B. Sometimes when we load a page for the first time, transitionEnd listener that we put in ScreenWrapper does not fire because there's no actual transition that goes on, the screen just loads.

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

A.
We should make sure to only focus the input after the transition ends and also the input is initialized. We can do that in a clean way as following:

  1. Create a hook useFocusOnTransitionEnd to encapsulate the logic of focusing the input when transition ends, it will focus the inputRef once both the transition ends and input is initialized
const useFocusOnTransitionEnd = () => {
    const inputRef = useRef(null);
    const [screenTransitionEnd, setScreenTransitionEnd] = React.useState(false);
    const [isInputInitialized, setIsInputInitialized] = React.useState(false);

    const onEntryTransitionEnd = () => {
        setScreenTransitionEnd(true);
    }

    useEffect(() => {
        if (screenTransitionEnd && isInputInitialized && inputRef.current) {
            inputRef.current.focus();
        }
    }, [screenTransitionEnd, isInputInitialized]);

    const inputCallbackRef = (ref) => {
        inputRef.current = ref;
        setIsInputInitialized(true);
    };

    return {onEntryTransitionEnd, inputCallbackRef};
}
  1. In here, use the hook
const {onEntryTransitionEnd, inputCallbackRef} = useFocusOnTransitionEnd();

In here

onEntryTransitionEnd={onEntryTransitionEnd}

In here

ref={inputCallbackRef}

It only requires 3 line changes in the page, the heavy lifting is already handled inside the hook. We can apply it everywhere that we're using the onEntryTransitionEnd approach to autofocus.

B. To fix this, we need to:

  • Initiate an app-wide variable like isFirstScreenLoaded which defaults to false.
  • In here
    componentDidMount() {
    , we need to check if the screen is focused and isFirstScreenLoaded is false, we set isFirstScreenLoaded to true and call onEntryTransitionEnd

This will make sure onEntryTransitionEnd will always be called for the first screen that is loaded.

What alternative solutions did you explore? (Optional)

NA

@melvin-bot melvin-bot bot added the Overdue label Jul 17, 2023
@greg-schroeder
Copy link
Contributor

Awaiting proposal review from @aimane-chnaif :)

@aimane-chnaif
Copy link
Contributor

@tienifr I like using hook but unfortunately this doesn't work because onEntryTransitionEnd is still not called upon refresh.

@tienifr
Copy link
Contributor

tienifr commented Jul 19, 2023

@aimane-chnaif it does call onEntryTransitionEnd when I test it just now actually, how were you able to reproduce it not calling?

@aimane-chnaif
Copy link
Contributor

@aimane-chnaif it does call onEntryTransitionEnd when I test it just now actually, how were you able to reproduce it not calling?

can you share your test branch? I tested on web

@tienifr
Copy link
Contributor

tienifr commented Jul 20, 2023

can you share your test branch? I tested on web

@aimane-chnaif here you go
https://github.com/Expensify/App/compare/main...tienifr:App:fix/22850?expand=1
When reloading the NewTaskDetailsPage, you'll see that onEntryTransitionEndIsCalled is logged to the console.

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Oct 10, 2023
@melvin-bot melvin-bot bot added Weekly KSv2 and removed Weekly KSv2 labels Oct 10, 2023
@mvtglobally
Copy link

Issue not reproducible during KI retests. (Second week)

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Oct 16, 2023
@melvin-bot melvin-bot bot changed the title [$1000] Web - Task title input is not focused after reloading the page [HOLD for payment 2023-10-23] [$1000] Web - Task title input is not focused after reloading the page Oct 16, 2023
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Oct 16, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 16, 2023

Reviewing label has been removed, please complete the "BugZero Checklist".

@melvin-bot
Copy link

melvin-bot bot commented Oct 16, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.84-10 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2023-10-23. 🎊

After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

  • External issue reporter
  • Contributor that fixed the issue
  • Contributor+ that helped on the issue and/or PR

For reference, here are some details about the assignees on this issue:

As a reminder, here are the bonuses/penalties that should be applied for any External issue:

  • Merged PR within 3 business days of assignment - 50% bonus
  • Merged PR more than 9 business days after assignment - 50% penalty

@melvin-bot
Copy link

melvin-bot bot commented Oct 16, 2023

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@aimane-chnaif] The PR that introduced the bug has been identified. Link to the PR:
  • [@aimane-chnaif] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
  • [@aimane-chnaif] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
  • [@aimane-chnaif] Determine if we should create a regression test for this bug.
  • [@aimane-chnaif] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@greg-schroeder] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@melvin-bot melvin-bot bot added Weekly KSv2 and removed Weekly KSv2 labels Oct 16, 2023
@melvin-bot melvin-bot bot changed the title [HOLD for payment 2023-10-23] [$1000] Web - Task title input is not focused after reloading the page [HOLD for payment 2023-10-23] [HOLD for payment 2023-10-23] [$1000] Web - Task title input is not focused after reloading the page Oct 16, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 16, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.84-10 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2023-10-23. 🎊

After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

  • External issue reporter
  • Contributor that fixed the issue
  • Contributor+ that helped on the issue and/or PR

For reference, here are some details about the assignees on this issue:

As a reminder, here are the bonuses/penalties that should be applied for any External issue:

  • Merged PR within 3 business days of assignment - 50% bonus
  • Merged PR more than 9 business days after assignment - 50% penalty

@melvin-bot
Copy link

melvin-bot bot commented Oct 16, 2023

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@aimane-chnaif] The PR that introduced the bug has been identified. Link to the PR:
  • [@aimane-chnaif] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
  • [@aimane-chnaif] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
  • [@aimane-chnaif] Determine if we should create a regression test for this bug.
  • [@aimane-chnaif] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@greg-schroeder] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@greg-schroeder greg-schroeder changed the title [HOLD for payment 2023-10-23] [HOLD for payment 2023-10-23] [$1000] Web - Task title input is not focused after reloading the page [HOLD for payment 2023-10-23] [$1000] Web - Task title input is not focused after reloading the page Oct 18, 2023
@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 Daily KSv2 labels Oct 23, 2023
@greg-schroeder
Copy link
Contributor

Processing

@greg-schroeder
Copy link
Contributor

Issue Participants:

Issue reported by: @gadhiyamanan
Contributor: @tienifr
C+: @aimane-chnaif

Was this issue merged in time to be eligible for the speed bonus? y
Were their any regressions? n

Payment summary:

Reporter: $250
Contributor: $1,500
C+: $1,500

@greg-schroeder
Copy link
Contributor

Offers sent. Next up is @aimane-chnaif to complete the c+ checklist

@greg-schroeder greg-schroeder changed the title [HOLD for payment 2023-10-23] [$1000] Web - Task title input is not focused after reloading the page [C+ Checklist Needs Completion] [$1000] Web - Task title input is not focused after reloading the page Oct 23, 2023
@aimane-chnaif
Copy link
Contributor

  • The PR that introduced the bug has been identified. Link to the PR: N/A
  • The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment: N/A
  • A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion: N/A
  • Determine if we should create a regression test for this bug. I don't suggest regression test as this doesn't affect task flow and reload is rare case.
  • If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.

@greg-schroeder
Copy link
Contributor

Thanks! Completing payments and closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering Internal Requires API changes or must be handled by Expensify staff
Projects
None yet
Development

No branches or pull requests