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

[HOLD for payment 2023-10-25] [$1000] Web - App maintains focus but does not scroll to bottom at cursor position on reload #27153

Closed
1 of 6 tasks
kbecciv opened this issue Sep 11, 2023 · 68 comments
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 External Added to denote the issue can be worked on by a contributor

Comments

@kbecciv
Copy link

kbecciv commented Sep 11, 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. Open any report
  3. Send big message that enables scroll
  4. Reload and observe that focus is on composer but it does not scroll to cursor position
  5. Click on any user profile to open details page and reload
  6. Click on back and observe that now app scrolls to bottom to cursor position

Expected Result:

App should scroll to cursor position if focus is maintained on composer box

Actual Result:

App maintains focus but does not scroll to bottom at cursor position in compose box

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.67.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

scroll.to.bottom.not.working.for.big.messages.1.mp4
Recording.4382.mp4

Expensify/Expensify Issue URL:
Issue reported by: @dhanashree-sawant
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1694063310399689

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01048bbbaff6031064
  • Upwork Job ID: 1701240589171867648
  • Last Price Increase: 2023-09-28
  • Automatic offers:
    • jjcoffee | Reviewer | 27014842
    • jeet-dhandha | Contributor | 27014844
    • dhanashree-sawant | Reporter | 27014846
@kbecciv kbecciv added External Added to denote the issue can be worked on by a contributor Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Sep 11, 2023
@melvin-bot melvin-bot bot changed the title Web - App maintains focus but does not scroll to bottom at cursor position on reload [$500] Web - App maintains focus but does not scroll to bottom at cursor position on reload Sep 11, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 11, 2023

Job added to Upwork: https://www.upwork.com/jobs/~01048bbbaff6031064

@melvin-bot
Copy link

melvin-bot bot commented Sep 11, 2023

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

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

melvin-bot bot commented Sep 11, 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

@melvin-bot
Copy link

melvin-bot bot commented Sep 11, 2023

Triggered auto assignment to @bfitzexpensify (External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.

@melvin-bot
Copy link

melvin-bot bot commented Sep 11, 2023

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

@binary3oul
Copy link

binary3oul commented Sep 11, 2023

Proposal

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

App maintains focus but does not scroll to bottom at cursor position on reload.

What is the root cause of that problem?

When we refresh the page, Composer component saves the position of the cursor whereas don't save scrollTop property.
In Composer component, we missed to set scrollTop propery of textInput.

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

We need to add a line to set scrollTop property like this:
textInput.current.scrollTop = textInput.current.scrollHeight;

in this line in useEffect hook.

Totally, the code looks like

useEffect(() => {
textInput.current.scrollTop = textInput.current.scrollHeight;

What alternative solutions did you explore? (Optional)

we can also use textInput.current.scrollTop = selectionProp.start

@usafhassan
Copy link

usafhassan commented Sep 11, 2023

Proposal

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

App maintains focus but does not scroll to bottom at cursor position on reload

What is the root cause of that problem?

Its refreshing, that is why it is losing the state

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

We need to add a single line of code to set the value of scrollTop

textInput.current.scrollTop = textInput.current.scrollHeight;

The updated code will look like this

 // rest of the code
 useEffect(() => {
    if (textareaRef.current && msgText) {
      textareaRef.current.scrollTop = textareaRef.current.scrollHeight;
    }
  }, []);
 // rest of the code

What alternative solutions did you explore? (Optional)

Contributor details
Your Expensify account email: usafhassan@gmail.com
Upwork Profile Link: https://www.upwork.com/freelancers/~0141ec503adff92d50

@melvin-bot
Copy link

melvin-bot bot commented Sep 11, 2023

📣 @usafhassan! 📣
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. 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.
  2. 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.
  3. 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>

@usafhassan
Copy link

Contributor details
Your Expensify account email: usafhassan@gmail.com
Upwork Profile Link: https://www.upwork.com/freelancers/~0141ec503adff92d50

@melvin-bot
Copy link

melvin-bot bot commented Sep 11, 2023

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

@jjcoffee
Copy link
Contributor

@usafhassan Welcome 👋 and thanks for your proposal! Please read our contributing guide and use the proposal template there.

For both proposals I think it'd be nice to add to the RCAs why steps 5 & 6 work to set the correct scroll position. @usafhassan @binary3oul

@binary3oul
Copy link

Updated Proposal

@jjcoffee
Copy link
Contributor

@binary3oul Thanks, I'm still interested in why steps 5 & 6 work to set the correct scroll position though 😄

@binary3oul
Copy link

When we refresh the page, Composer component saves the position of the cursor whereas don't save scrollTop property.
In Composer component, we missed to set scrollTop propery of textInput.

@jjcoffee
Copy link
Contributor

Specifically why does this step currently work though:

Click on back and observe that now app scrolls to bottom to cursor position

@usafhassan
Copy link

usafhassan commented Sep 13, 2023

@jjcoffee
The step 5 and 6 works because when we go back to the report page where we are writing a long message,
that page is still maintaining it's state (or getting from a global store/redux store), as we did not reload that page(report page),
even though we reloaded the details page, it does not affect the state of report page and we still go to cursor position.

P.S. I have updated my proposal according to the template

@jjcoffee
Copy link
Contributor

@usafhassan Thanks, but my point is even if I scroll up to the top of the message and then perform the same steps (open details page, reload, go back), the input is scrolled to the bottom. I think it'd be useful to understand what's happening there as presumably we could use the same on reload to keep things nice and clean!

@usafhassan
Copy link

@jjcoffee when we close the side menu, the useEffect runs which calls the focus() function

@usafhassan
Copy link

@jjcoffee also we can add another dependency variable for reload and set it to true in initial state, then add it in dependency array of useEffect where we are setting the scroll position, this will set it to correct position on reload

@melvin-bot melvin-bot bot added the Overdue label Sep 18, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 18, 2023

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

@jjcoffee
Copy link
Contributor

Reviewing tomorrow!

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Oct 4, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 4, 2023

📣 @jjcoffee 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job

@melvin-bot
Copy link

melvin-bot bot commented Oct 4, 2023

📣 @jeet-dhandha 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job
Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

@melvin-bot
Copy link

melvin-bot bot commented Oct 4, 2023

📣 @dhanashree-sawant 🎉 An offer has been automatically sent to your Upwork account for the Reporter role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job

@jeet-dhandha
Copy link
Contributor

@jjcoffee - There's an issue with Mobile Safari its auto-focusing by default. This is happening in main also. Should we handle it in a different PR ?

@jeet-dhandha
Copy link
Contributor

jeet-dhandha commented Oct 4, 2023

All mobile devices don't focus, when its not an empty chat.

MobileSafari.mp4

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Oct 4, 2023
@jjcoffee
Copy link
Contributor

jjcoffee commented Oct 5, 2023

@jeet-dhandha Yeah I would say if there's a general issue on native devices that the composer isn't focused (whether intentional or not), that would be out of scope for this issue. Feel free to report it!

@dylanexpensify
Copy link
Contributor

@jeet-dhandha @jjcoffee mind giving us an update?

@jjcoffee
Copy link
Contributor

@dylanexpensify PR is under review - just needed quite a bit of back and forth to get the code in shape!

@jeet-dhandha
Copy link
Contributor

jeet-dhandha commented Oct 10, 2023

@jjcoffee I have asked u to review again but seems like u r busy with other tasks.

CC: @dylanexpensify

@melvin-bot
Copy link

melvin-bot bot commented Oct 17, 2023

Based on my calculations, the pull request did not get merged within 3 working days of assignment. Please, check out my computations here:

  • when @jeet-dhandha got assigned: 2023-10-04 09:36:40 Z
  • when the PR got merged: 2023-10-17 15:36:13 UTC
  • days elapsed: 9

On to the next one 🚀

@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 18, 2023
@melvin-bot melvin-bot bot changed the title [$1000] Web - App maintains focus but does not scroll to bottom at cursor position on reload [HOLD for payment 2023-10-25] [$1000] Web - App maintains focus but does not scroll to bottom at cursor position on reload Oct 18, 2023
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Oct 18, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 18, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Oct 18, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.86-5 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-25. 🎊

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 18, 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:

  • [@jjcoffee] The PR that introduced the bug has been identified. Link to the PR:
  • [@jjcoffee] 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:
  • [@jjcoffee] 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:
  • [@jjcoffee] Determine if we should create a regression test for this bug.
  • [@jjcoffee] 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.
  • [@bfitzexpensify / @dylanexpensify] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@dylanexpensify
Copy link
Contributor

payment tomorrow!

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Oct 25, 2023
@jeet-dhandha
Copy link
Contributor

Bump for payment

@jjcoffee
Copy link
Contributor

  • The PR that introduced the bug has been identified. Link to the PR: N/A - we've never handled this
  • 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. Yes
  • 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.

Regression test proposal

  1. Open any report
  2. Enter a long enough text to make composer take full height and scroll bars appear
  3. Refresh the page of that report.
  4. Verify that the composer is scrolled to the bottom for all platforms except iOS.

Do we agree 👍 or 👎

@bfitzexpensify
Copy link
Contributor

Payments complete - will review the proposed regression steps tomorrow

@bfitzexpensify
Copy link
Contributor

Regression steps look good, opened an issue to get it updated. We're all done here, thanks everyone

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 External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests

9 participants