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-07-28] [$1000] Dev: IOS - Getting console warning on the Payments page when pressing Add payment method button #21953

Closed
1 of 6 tasks
kbecciv opened this issue Jun 30, 2023 · 41 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Engineering External Added to denote the issue can be worked on by a contributor Monthly KSv2

Comments

@kbecciv
Copy link

kbecciv commented Jun 30, 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 App and Go to Settings > Payments
  2. Press Add payment method button

Expected Result:

Should not show any console warnings

Actual Result:

Getting Console Warnings (The prop anchorPosition.horizontal is marked as required in PopoverMenu, but its value is undefined)

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: iOS (Dev)
Reproducible in staging?: n/a
Reproducible in production?: n/a
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

console-bug-ios-anchorPosition.horizontal.mov

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

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0151ff298169cff532
  • Upwork Job ID: 1679538004659675136
  • Last Price Increase: 2023-07-13
@kbecciv kbecciv added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jun 30, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jun 30, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Jun 30, 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

@kbecciv
Copy link
Author

kbecciv commented Jun 30, 2023

Proposal

from: @jayeshmangwani

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

Getting console warning on the Payments page when pressing Add payment method button

What is the root cause of that problem?

The issue is happening because, on BasePaymentsPage, we pass the horizontal: this.state.anchorPositionHorizontal to AddPaymentMethodMenu Component, and the horizontal value should be the number horizontal: PropTypes.number When we press the Add payment method button at that time, we are setting the horizontal: undefined and this should be a number value

  1. Here, on AddPaymentMethodMenu anchorPosition's horizontal value should be the number

    /** Anchor position for the AddPaymentMenu. */
    anchorPosition: PropTypes.shape({
    horizontal: PropTypes.number,
    vertical: PropTypes.number,
    }),

  2. And we are passing the anchorPosition value from BasePaymentsPage to AddPaymentMethodMenu

    <AddPaymentMethodMenu
    isVisible={this.state.shouldShowAddPaymentMenu}
    onClose={this.hideAddPaymentMenu}
    anchorPosition={{
    horizontal: this.state.anchorPositionHorizontal,
    vertical: this.state.anchorPositionVertical - 10,
    }}
    onItemSelected={(method) => this.addPaymentMethodTypePressed(method)}
    />

  3. On Add payment method button we call the paymentMethodPressed function and on this function, we calculate the position of the click

    paymentMethodPressed(nativeEvent, accountType, account, isDefault, methodID) {
    const position = getClickedTargetLocation(nativeEvent.currentTarget);

    And Then We call the setPositionAddPaymentMenu
    this.setPositionAddPaymentMenu(position);

    getClickedTargetLocation values will be different for Mobile Devices and Web, For the web, we calculate this by using the getBoundingClientRect method of HTML DOM Element, and its returns the eight properties left top, right, bottom, x, y, width, height
    function getClickedTargetLocation(target) {
    return target.getBoundingClientRect();
    }

    And for Mobile devices(Android and IOS), We return only bottom and left values
    return {
    bottom: 0,
    left: 0,
    };

  4. And On mobile devices when we call setPositionAddPaymentMenu with the position object that we have calculated from getClickedTargetLocation, There will be only bottom and left values for the mobile devices, and here anchorPositionHorizontal expects the x value, but x is undefined.
    And that's why we are getting this error as anchorPositionHorizontal should be a number, and here we are getting undefined.

    setPositionAddPaymentMenu(position) {
    this.setState({
    anchorPositionTop: position.top + position.height + variables.addPaymentPopoverTopSpacing,
    // We want the position to be 13px to the right of the left border
    anchorPositionRight: this.props.windowWidth - position.right + variables.addPaymentPopoverRightSpacing,
    anchorPositionHorizontal: position.x,
    anchorPositionVertical: position.y,
    });
    }

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

On the getClickedTargetLocation function, we should return the x and y too, On mobile devices we use the bottom-docked modal so we actually don't need the anchorPosition so here we should add the x and y values to 0 as, horizontal and vertical values expecting a number

return {
bottom: 0,
left: 0,
};

    return {
        bottom: 0,
        left: 0,
        x: 0,
        y: 0,
    };

And on top of that, we should add missing values top, right, width, height with value 0 as anchorPositionTop is also expecting the number value of top and height; anchorpositionright expects the right value to be a number.

What alternative solutions did you explore? (Optional)

We should pass the anchorPosition value conditionally when there is no Small screen device, then pass the anchorPosition

<AddPaymentMethodMenu
isVisible={this.state.shouldShowAddPaymentMenu}
onClose={this.hideAddPaymentMenu}
anchorPosition={{
horizontal: this.state.anchorPositionHorizontal,
vertical: this.state.anchorPositionVertical - 10,
}}
onItemSelected={(method) => this.addPaymentMethodTypePressed(method)}
/>

{...(!this.props.isSmallScreenWidth ? {anchorPosition} : {})}

@jayeshmangwani
Copy link
Contributor

Proposal

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

Getting console warning on the Payments page when pressing Add payment method button

What is the root cause of that problem?

The issue is happening because, on BasePaymentsPage, we pass the horizontal: this.state.anchorPositionHorizontal to AddPaymentMethodMenu Component, and the horizontal value should be the number horizontal: PropTypes.number When we press the Add payment method button at that time, we are setting the horizontal: undefined and this should be a number value

  1. Here, on AddPaymentMethodMenu anchorPosition's horizontal value should be the number

    /** Anchor position for the AddPaymentMenu. */
    anchorPosition: PropTypes.shape({
    horizontal: PropTypes.number,
    vertical: PropTypes.number,
    }),

  2. And we are passing the anchorPosition value from BasePaymentsPage to AddPaymentMethodMenu

    <AddPaymentMethodMenu
    isVisible={this.state.shouldShowAddPaymentMenu}
    onClose={this.hideAddPaymentMenu}
    anchorPosition={{
    horizontal: this.state.anchorPositionHorizontal,
    vertical: this.state.anchorPositionVertical - 10,
    }}
    onItemSelected={(method) => this.addPaymentMethodTypePressed(method)}
    />

  3. On Add payment method button we call the paymentMethodPressed function and on this function, we calculate the position of the click

    paymentMethodPressed(nativeEvent, accountType, account, isDefault, methodID) {
    const position = getClickedTargetLocation(nativeEvent.currentTarget);

    And Then We call the setPositionAddPaymentMenu
    this.setPositionAddPaymentMenu(position);

    getClickedTargetLocation values will be different for Mobile Devices and Web, For the web, we calculate this by using the getBoundingClientRect method of HTML DOM Element, and its returns the eight properties left top, right, bottom, x, y, width, height
    function getClickedTargetLocation(target) {
    return target.getBoundingClientRect();
    }

    And for Mobile devices(Android and IOS), We return only bottom and left values
    return {
    bottom: 0,
    left: 0,
    };

  4. And On mobile devices when we call setPositionAddPaymentMenu with the position object that we have calculated from getClickedTargetLocation, There will be only bottom and left values for the mobile devices, and here anchorPositionHorizontal expects the x value, but x is undefined.
    And that's why we are getting this error as anchorPositionHorizontal should be a number, and here we are getting undefined.

    setPositionAddPaymentMenu(position) {
    this.setState({
    anchorPositionTop: position.top + position.height + variables.addPaymentPopoverTopSpacing,
    // We want the position to be 13px to the right of the left border
    anchorPositionRight: this.props.windowWidth - position.right + variables.addPaymentPopoverRightSpacing,
    anchorPositionHorizontal: position.x,
    anchorPositionVertical: position.y,
    });
    }

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

On the getClickedTargetLocation function, we should return the x and y too, On mobile devices we use the bottom-docked modal so we actually don't need the anchorPosition so here we should add the x and y values to 0 as, horizontal and vertical values expecting a number

return {
bottom: 0,
left: 0,
};

    return {
        bottom: 0,
        left: 0,
        x: 0,
        y: 0,
    };

And on top of that, we should add missing values top, right, width, height with value 0 as anchorPositionTop is also expecting the number value of top and height; anchorpositionright expects the right value to be a number.

What alternative solutions did you explore? (Optional)

We should pass the anchorPosition value conditionally when there is no Small screen device, then pass the anchorPosition

<AddPaymentMethodMenu
isVisible={this.state.shouldShowAddPaymentMenu}
onClose={this.hideAddPaymentMenu}
anchorPosition={{
horizontal: this.state.anchorPositionHorizontal,
vertical: this.state.anchorPositionVertical - 10,
}}
onItemSelected={(method) => this.addPaymentMethodTypePressed(method)}
/>

{...(!this.props.isSmallScreenWidth ? {anchorPosition} : {})}

@melvin-bot melvin-bot bot added the Overdue label Jul 3, 2023
@muttmuure
Copy link
Contributor

https://expensify.slack.com/archives/C01GTK53T8Q/p1688406242558149

Not sure we're supposed to fix bugs on dev

@melvin-bot melvin-bot bot removed the Overdue label Jul 3, 2023
@muttmuure
Copy link
Contributor

Asking what I need to do if something is a deploy blocker

@melvin-bot melvin-bot bot added the Overdue label Jul 7, 2023
@jayeshmangwani
Copy link
Contributor

@muttmuure This issue is not the deploy blocker. Above is the console warning, and this console warning issue does not happen on staging or production, and this warning is displayed when run from the local main branch.

Few GH issues, example for, console warnings/errors #22206, #22169, #21840

@muttmuure
Copy link
Contributor

So is the answer to these questions: no

Reproducible in staging?: n/a
Reproducible in production?: n/a

?

@melvin-bot melvin-bot bot removed the Overdue label Jul 10, 2023
@jayeshmangwani
Copy link
Contributor

So is the answer to these questions: no

Reproducible in staging?: n/a Reproducible in production?: n/a

?

Yes, I think so
Screenshot 2023-07-10 at 8 09 44 PM

For #22206 issue, we have added dev, so for this issue too we can say dev

Screenshot 2023-07-10 at 8 11 11 PM

@melvin-bot melvin-bot bot added the Overdue label Jul 12, 2023
@muttmuure
Copy link
Contributor

Not sure how I can reproduce this, so I've asked about getting console logs for iOS here: https://expensify.slack.com/archives/C01SKUP7QR0/p1689246208691599

@melvin-bot melvin-bot bot removed the Overdue label Jul 13, 2023
@Julesssss
Copy link
Contributor

Don't think you'll be able to. We should get an internal engineer to verify

@melvin-bot
Copy link

melvin-bot bot commented Jul 13, 2023

Triggered auto assignment to @stitesExpensify (Engineering), see https://stackoverflow.com/c/expensify/questions/4319 for more details.

@muttmuure
Copy link
Contributor

Adding engineering to ask if they can reproduce.

@stitesExpensify
Copy link
Contributor

Confirmed. I am getting the same error on web too
2023-07-13_11-04-54

@stitesExpensify
Copy link
Contributor

Just kidding that's actually a different error 😅

@stitesExpensify
Copy link
Contributor

I am also getting the error described in the OP

2023-07-13_11-06-28

@stitesExpensify stitesExpensify added the External Added to denote the issue can be worked on by a contributor label Jul 13, 2023
@melvin-bot melvin-bot bot changed the title Dev: IOS - Getting console warning on the Payments page when pressing Add payment method button [$1000] Dev: IOS - Getting console warning on the Payments page when pressing Add payment method button Jul 13, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jul 13, 2023

Job added to Upwork: https://www.upwork.com/jobs/~0151ff298169cff532

@melvin-bot melvin-bot bot changed the title [$1000] Dev: IOS - Getting console warning on the Payments page when pressing Add payment method button [HOLD for payment 2023-07-28] [$1000] Dev: IOS - Getting console warning on the Payments page when pressing Add payment method button Jul 21, 2023
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jul 21, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jul 21, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Jul 21, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.43-7 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-07-28. 🎊

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 Jul 21, 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:

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

@melvin-bot melvin-bot bot added Daily KSv2 Monthly KSv2 Overdue and removed Weekly KSv2 labels Jul 27, 2023
@muttmuure
Copy link
Contributor

@jayeshmangwani paid urgency bonus and reporting bonus

@0xmiroslav invited to apply to job on Upwork

@melvin-bot melvin-bot bot removed the Overdue label Jul 31, 2023
@0xmiros
Copy link
Contributor

0xmiros commented Jul 31, 2023

@muttmuure Sorry, can you please hold my payment until further notice? I am working on some stuff due to recent measurements in my region. And update issue to Monthly. Thanks

@melvin-bot melvin-bot bot added the Overdue label Aug 2, 2023
@melvin-bot
Copy link

melvin-bot bot commented Aug 3, 2023

@jayeshmangwani, @stitesExpensify, @muttmuure, @0xmiroslav Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@stitesExpensify
Copy link
Contributor

Holding payment

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Aug 3, 2023
@melvin-bot
Copy link

melvin-bot bot commented Aug 7, 2023

@jayeshmangwani, @stitesExpensify, @muttmuure, @0xmiroslav Whoops! This issue is 2 days overdue. Let's get this updated quick!

@stitesExpensify stitesExpensify removed the Daily KSv2 label Aug 8, 2023
@stitesExpensify
Copy link
Contributor

@0xmiroslav any update? Or are we still holding your payment?

@melvin-bot melvin-bot bot removed the Overdue label Aug 8, 2023
@0xmiros
Copy link
Contributor

0xmiros commented Aug 8, 2023

still holding my payment. will update here when ready

@melvin-bot melvin-bot bot added the Overdue label Sep 11, 2023
@0xmiros
Copy link
Contributor

0xmiros commented Sep 12, 2023

Not overdue

@melvin-bot melvin-bot bot removed the Overdue label Sep 12, 2023
@melvin-bot melvin-bot bot added the Overdue label Oct 13, 2023
@stitesExpensify
Copy link
Contributor

@0xmiroslav what's the status here?

@melvin-bot melvin-bot bot removed the Overdue label Oct 16, 2023
@0xmiros
Copy link
Contributor

0xmiros commented Oct 16, 2023

Please close this one. I am tracking myself. Thanks

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

No branches or pull requests

6 participants