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-09-21] [$500] [Distance] - There is NO animation of the transition when I have entered start and finish points #26723

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

Comments

@lanitochka17
Copy link

lanitochka17 commented Sep 4, 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!


Issue found when executing PR #26610

Action Performed:

  1. Open app on small screen (height = +- 400px )
  2. Go to FAB -> Request money -> Distance
  3. Enter start and finish points
  4. Click "Add stope"

Expected Result:

Should be an animation of the transition of the list elements to the end

Actual Result:

There is NO animation of the transition of the list elements to the end

Workaround:

Unknown

Platforms:

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

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

Version Number: 1.3.63-0

Reproducible in staging?: Yes

Reproducible in production?: Yes

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

Bug6188423_Recording__6138.3.mp4

Expensify/Expensify Issue URL:

Issue reported by: Applause - Internal Team

Slack conversation:

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0116cd2b0228d37197
  • Upwork Job ID: 1699803735595442176
  • Last Price Increase: 2023-09-07
  • Automatic offers:
    • jjcoffee | Reviewer | 26572301
    • bernhardoj | Contributor | 26572302
@lanitochka17 lanitochka17 added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Sep 4, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 4, 2023

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

@melvin-bot
Copy link

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

@jscardona12
Copy link
Contributor

jscardona12 commented Sep 4, 2023

Proposal

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

Distance - There is NO animation of the transition when I have entered start and finish points.

What is the root cause of that problem?

The line

scrollViewRef.current.scrollToEnd({animated: true});
scrollToEnd does not work.

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

We should modify

scrollViewRef.current.scrollToEnd({animated: true});
and set it as scrollViewRef.current.scrollTo({y:height, animated: true});

Solution Working

Screen.Recording.2023-09-04.at.4.40.43.PM.mov

What alternative solutions did you explore? (Optional)

@DylanDylann
Copy link
Contributor

DylanDylann commented Sep 5, 2023

Proposal

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

There is NO animation of the transition when I have entered start and finish points

What is the root cause of that problem?

We are using usePrevious hook to save the previous waypoint. When this component is re-render 2 times, for example, waypoints are 2. The first re-rendering Waypoints is updated to 3 and previousWaypoints is updated to 2, the second re-rendering Waypoints is not updated but the previousWaypoints still updated to 3 (the value of Waypoints in the first time). It causes that numberOfWaypoints = numberOfPreviousWaypoints

if (scrollContentHeight < height && numberOfWaypoints > numberOfPreviousWaypoints) {
scrollViewRef.current.scrollToEnd({animated: true});
}

scrollToEnd function is not called because numberOfWaypoints = numberOfPreviousWaypoints

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

if (scrollContentHeight < height && numberOfWaypoints > numberOfPreviousWaypoints) {
scrollViewRef.current.scrollToEnd({animated: true});
}

In here, we can remove the condition numberOfWaypoints > numberOfPreviousWaypoints
It still works well

Screen.Recording.2023-09-05.at.15.30.44.mov

What alternative solutions did you explore? (Optional)

We only update numberOfPreviousWaypoints if numberOfWaypoints changed

    const numberOfPreviousWaypoints = useMemo(() => _.size(previousWaypoints), [numberOfWaypoints]);

@lanitochka17 lanitochka17 changed the title Distance - There is NO animation of the transition when I have entered start and finish points [Distance] - There is NO animation of the transition when I have entered start and finish points Sep 5, 2023
@bernhardoj
Copy link
Contributor

Proposal

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

Adding a new stop to the distance request didn't scroll the waypoint list to the bottom. This issue only happens if we fill in at least 2 valid waypoints.

What is the root cause of that problem?

Adding a new stop will increase the number of waypoints. We use ScrollView onContentSizeChange to decide whether we should scroll to the bottom or not.

onContentSizeChange={(width, height) => {
if (scrollContentHeight < height && numberOfWaypoints > numberOfPreviousWaypoints) {
scrollViewRef.current.scrollToEnd({animated: true});
}
setScrollContentHeight(height);
}}

The failing condition in our case is numberOfWaypoints > numberOfPreviousWaypoints. When we don't fill any of the waypoints, this condition works fine, but when we fill at least 2 valid waypoints, the condition starts to fail. Why?

numberOfPreviousWaypoints uses usePrevious to store the previous value.

const waypoints = useMemo(() => lodashGet(transaction, 'comment.waypoints', {}), [transaction]);
const previousWaypoints = usePrevious(waypoints);
const numberOfWaypoints = _.size(waypoints);
const numberOfPreviousWaypoints = _.size(previousWaypoints);

However, usePrevious stores the previous value of the previous render. When the component is rerendered once again, the previous value now is the same as the current value. So, if something triggers the re-render before onContentSizeChange is called, numberOfWaypoints becomes equal to numberOfPreviousWayPoints. But what is causing the re-render? Transaction.getRoute

useEffect(() => {
if (isOffline || !shouldFetchRoute) {
return;
}
Transaction.getRoute(iou.transactionID, validatedWaypoints);
}, [shouldFetchRoute, iou.transactionID, validatedWaypoints, isOffline]);

Transaction.getRoute will be called when shouldFetchRoute becomes true. One of the conditions of shouldFetchRoute is to have more than 1 valid waypoint.

const shouldFetchRoute = (!doesRouteExist || haveWaypointsChanged) && !isLoadingRoute && _.size(validatedWaypoints) > 1;

So let's say we have 2 valid waypoints, then we add a new stop. Transaction.getRoute will happen first before ScrollView onContentSizeChange is triggered, which will re-render the component because we are merging optimistic data on doing the request.

That's why the issue only happens when we have at least 2 valid waypoints.

With 2 valid waypoints
Screenshot 2023-09-06 at 16 55 27

Without valid waypoints
Screenshot 2023-09-06 at 16 22 04

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

I think checking the ScrollView content height changes is unnecessary. Adding a new stop will always increase the content height. I believe what we want is to always scroll to the bottom every time we add a new stop, so both my main and alternative solutions will not depends the content height value.

The simplest solution is to scroll to the bottom on every "Add stop" button click.

Transaction.addStop(iou.transactionID).then(/** scroll to bottom **/);

addStop will now return the onyx merge so we can wait for the promise until it completes before doing the scroll.

What alternative solutions did you explore? (Optional)

Scroll to the bottom immediately when the number of waypoints is changed.

useEffect(() => {
    if (numberOfWaypoints > numberOfPreviousWaypoints) {
        scrollViewRef.current.scrollToEnd({animated: true});
    }
}, [numberOfWaypoints, numberOfPreviousWaypoints]);

@arosiclair arosiclair self-assigned this Sep 7, 2023
@puneetlath puneetlath added the External Added to denote the issue can be worked on by a contributor label Sep 7, 2023
@melvin-bot melvin-bot bot changed the title [Distance] - There is NO animation of the transition when I have entered start and finish points [$500] [Distance] - There is NO animation of the transition when I have entered start and finish points Sep 7, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 7, 2023

Job added to Upwork: https://www.upwork.com/jobs/~0116cd2b0228d37197

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

melvin-bot bot commented Sep 7, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Sep 7, 2023

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

@puneetlath
Copy link
Contributor

@jjcoffee thoughts on the proposals so far?

@melvin-bot melvin-bot bot removed the Overdue label Sep 7, 2023
@jjcoffee
Copy link
Contributor

jjcoffee commented Sep 8, 2023

@jscardona12's proposal lacks enough detail to fully review - there's no "why" in either the RCA or the proposed solution. Maybe the solution works (as the video demonstrates), but we'd want to be sure we're actually fixing a problem, not just making something work without understanding what we're doing.

@DylanDylann's proposal has the correct RCA (numberOfPreviousWaypoints isn't always what we'd expect), but misses a little bit on what actually causes the re-render. The solution seems decent, but has the downside that we'll scroll to the bottom on any onContentSizeChange, e.g. if you remove a waypoint you'll also be scrolled to the bottom which isn't necessarily expected behaviour (and probably why the numberOfWaypoints condition was added).

@bernhardoj's proposal - love the level of detail and clarity here! The RCA is correct too, but also explains why the behaviour happens only once you add the start and finish points. I agree with him that we always want to scroll to the bottom when a new waypoint is added, regardless of ScrollView content height (so we can just ignore it). I think I prefer the alternative solution as the delay when waiting for the Onyx promise to resolve feels a bit too long and is unnecessary. The alternative solution also feels cleaner than slapping a scroll right onto the addStop call.

To summarise, happy to go with @bernhardoj's alternative solution!

🎀👀🎀 C+ reviewed

@melvin-bot
Copy link

melvin-bot bot commented Sep 8, 2023

Current assignees @puneetlath and @arosiclair are eligible for the choreEngineerContributorManagement assigner, not assigning anyone new.

@arosiclair
Copy link
Contributor

@bernhardoj's alternate solution LGTM too 👍

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

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

📣 @bernhardoj 🎉 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 melvin-bot bot added Weekly KSv2 and removed Daily KSv2 labels Sep 9, 2023
@bernhardoj
Copy link
Contributor

PR is ready

cc: @jjcoffee

@melvin-bot
Copy link

melvin-bot bot commented Sep 12, 2023

🎯 ⚡️ Woah @jjcoffee / @bernhardoj, great job pushing this forwards! ⚡️

The pull request got merged within 3 working days of assignment, so this job is eligible for a 50% #urgency bonus 🎉

  • when @bernhardoj got assigned: 2023-09-08 21:33:43 Z
  • when the PR got merged: 2023-09-12 15:02:05 UTC

On to the next one 🚀

@Expensify Expensify deleted a comment from melvin-bot bot Sep 13, 2023
@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Sep 14, 2023
@melvin-bot melvin-bot bot changed the title [$500] [Distance] - There is NO animation of the transition when I have entered start and finish points [HOLD for payment 2023-09-21] [$500] [Distance] - There is NO animation of the transition when I have entered start and finish points Sep 14, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 14, 2023

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

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Sep 14, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 14, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.69-2 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-09-21. 🎊

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 Sep 14, 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.
  • [@puneetlath] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@jjcoffee
Copy link
Contributor

  • The PR that introduced the bug has been identified. Link to the PR: Ensure multiple waypoints are visible on smaller screens #26610
  • 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: Ensure multiple waypoints are visible on smaller screens #26610 (comment)
  • 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 - just needed more thorough testing
  • Determine if we should create a regression test for this bug. No - not impactful enough, more of a "nice to have"
  • 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. N/A

@melvin-bot melvin-bot bot added Daily KSv2 Overdue and removed Weekly KSv2 labels Sep 21, 2023
@puneetlath
Copy link
Contributor

All paid. Thanks everyone!

@melvin-bot melvin-bot bot removed the Overdue label Sep 24, 2023
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 External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests

7 participants