Skip to content

Commit

Permalink
Merge pull request #9552 from liyamahendra/9283
Browse files Browse the repository at this point in the history
Solved the overlapping of payment options when clicking on 'Add Payment Method'
  • Loading branch information
marcaaron authored Aug 30, 2022
2 parents 0229523 + 151e27b commit 8e07c62
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
8 changes: 4 additions & 4 deletions src/components/KYCWall/BaseKYCWall.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import themeColors from '../../styles/themes/default';
import CONST from '../../CONST';
import Navigation from '../../libs/Navigation/Navigation';
import AddPaymentMethodMenu from '../AddPaymentMethodMenu';
import getClickedElementLocation from '../../libs/getClickedElementLocation';
import getClickedTargetLocation from '../../libs/getClickedTargetLocation';
import * as PaymentUtils from '../../libs/PaymentUtils';
import * as PaymentMethods from '../../libs/actions/PaymentMethods';
import ONYXKEYS from '../../ONYXKEYS';
Expand Down Expand Up @@ -48,7 +48,7 @@ class KYCWall extends React.Component {
if (!this.state.transferBalanceButton) {
return;
}
const buttonPosition = getClickedElementLocation(this.state.transferBalanceButton);
const buttonPosition = getClickedTargetLocation(this.state.transferBalanceButton);
const position = this.getAnchorPosition(buttonPosition);
this.setPositionAddPaymentMenu(position);
}
Expand Down Expand Up @@ -92,13 +92,13 @@ class KYCWall extends React.Component {
*/
continue(event) {
this.setState({
transferBalanceButton: event.nativeEvent,
transferBalanceButton: event.nativeEvent.target,
});

// Check to see if user has a valid payment method on file and display the add payment popover if they don't
if (!PaymentUtils.hasExpensifyPaymentMethod(this.props.cardList, this.props.bankAccountList)) {
Log.info('[KYC Wallet] User does not have valid payment method');
const clickedElementLocation = getClickedElementLocation(event.nativeEvent);
const clickedElementLocation = getClickedTargetLocation(event.nativeEvent.target);
const position = this.getAnchorPosition(clickedElementLocation);
this.setPositionAddPaymentMenu(position);
this.setState({
Expand Down
11 changes: 0 additions & 11 deletions src/libs/getClickedElementLocation/index.js

This file was deleted.

11 changes: 11 additions & 0 deletions src/libs/getClickedTargetLocation/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* Returns the Bounding Rectangle for the passed native event's target.
*
* @param {Object} target
* @returns {Object}
*/
function getClickedTargetLocation(target) {
return target.getBoundingClientRect();
}

export default getClickedTargetLocation;
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
*
* @returns {Object}
*/
function getClickedElementLocation() {
function getClickedTargetLocation() {
return {
bottom: 0,
left: 0,
};
}

export default getClickedElementLocation;
export default getClickedTargetLocation;
8 changes: 4 additions & 4 deletions src/pages/settings/Payments/PaymentsPage/BasePaymentsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import Popover from '../../../../components/Popover';
import MenuItem from '../../../../components/MenuItem';
import Text from '../../../../components/Text';
import * as PaymentMethods from '../../../../libs/actions/PaymentMethods';
import getClickedElementLocation from '../../../../libs/getClickedElementLocation';
import getClickedTargetLocation from '../../../../libs/getClickedTargetLocation';
import withWindowDimensions from '../../../../components/withWindowDimensions';
import CurrentWalletBalance from '../../../../components/CurrentWalletBalance';
import ONYXKEYS from '../../../../ONYXKEYS';
Expand Down Expand Up @@ -90,7 +90,7 @@ class BasePaymentsPage extends React.Component {
if (!this.state.addPaymentMethodButton) {
return;
}
const buttonPosition = getClickedElementLocation(this.state.addPaymentMethodButton);
const buttonPosition = getClickedTargetLocation(this.state.addPaymentMethodButton);
this.setPositionAddPaymentMenu(buttonPosition);
}

Expand Down Expand Up @@ -129,9 +129,9 @@ class BasePaymentsPage extends React.Component {
* @param {Boolean} isDefault
*/
paymentMethodPressed(nativeEvent, accountType, account, isDefault) {
const position = getClickedElementLocation(nativeEvent);
const position = getClickedTargetLocation(nativeEvent.currentTarget);
this.setState({
addPaymentMethodButton: nativeEvent,
addPaymentMethodButton: nativeEvent.currentTarget,
});
if (accountType) {
let formattedSelectedPaymentMethod;
Expand Down

0 comments on commit 8e07c62

Please sign in to comment.