Skip to content

Commit 8e07c62

Browse files
authored
Merge pull request #9552 from liyamahendra/9283
Solved the overlapping of payment options when clicking on 'Add Payment Method'
2 parents 0229523 + 151e27b commit 8e07c62

File tree

5 files changed

+21
-21
lines changed

5 files changed

+21
-21
lines changed

src/components/KYCWall/BaseKYCWall.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import themeColors from '../../styles/themes/default';
55
import CONST from '../../CONST';
66
import Navigation from '../../libs/Navigation/Navigation';
77
import AddPaymentMethodMenu from '../AddPaymentMethodMenu';
8-
import getClickedElementLocation from '../../libs/getClickedElementLocation';
8+
import getClickedTargetLocation from '../../libs/getClickedTargetLocation';
99
import * as PaymentUtils from '../../libs/PaymentUtils';
1010
import * as PaymentMethods from '../../libs/actions/PaymentMethods';
1111
import ONYXKEYS from '../../ONYXKEYS';
@@ -48,7 +48,7 @@ class KYCWall extends React.Component {
4848
if (!this.state.transferBalanceButton) {
4949
return;
5050
}
51-
const buttonPosition = getClickedElementLocation(this.state.transferBalanceButton);
51+
const buttonPosition = getClickedTargetLocation(this.state.transferBalanceButton);
5252
const position = this.getAnchorPosition(buttonPosition);
5353
this.setPositionAddPaymentMenu(position);
5454
}
@@ -92,13 +92,13 @@ class KYCWall extends React.Component {
9292
*/
9393
continue(event) {
9494
this.setState({
95-
transferBalanceButton: event.nativeEvent,
95+
transferBalanceButton: event.nativeEvent.target,
9696
});
9797

9898
// Check to see if user has a valid payment method on file and display the add payment popover if they don't
9999
if (!PaymentUtils.hasExpensifyPaymentMethod(this.props.cardList, this.props.bankAccountList)) {
100100
Log.info('[KYC Wallet] User does not have valid payment method');
101-
const clickedElementLocation = getClickedElementLocation(event.nativeEvent);
101+
const clickedElementLocation = getClickedTargetLocation(event.nativeEvent.target);
102102
const position = this.getAnchorPosition(clickedElementLocation);
103103
this.setPositionAddPaymentMenu(position);
104104
this.setState({

src/libs/getClickedElementLocation/index.js

-11
This file was deleted.
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* Returns the Bounding Rectangle for the passed native event's target.
3+
*
4+
* @param {Object} target
5+
* @returns {Object}
6+
*/
7+
function getClickedTargetLocation(target) {
8+
return target.getBoundingClientRect();
9+
}
10+
11+
export default getClickedTargetLocation;

src/libs/getClickedElementLocation/index.native.js renamed to src/libs/getClickedTargetLocation/index.native.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
*
44
* @returns {Object}
55
*/
6-
function getClickedElementLocation() {
6+
function getClickedTargetLocation() {
77
return {
88
bottom: 0,
99
left: 0,
1010
};
1111
}
1212

13-
export default getClickedElementLocation;
13+
export default getClickedTargetLocation;

src/pages/settings/Payments/PaymentsPage/BasePaymentsPage.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import Popover from '../../../../components/Popover';
1919
import MenuItem from '../../../../components/MenuItem';
2020
import Text from '../../../../components/Text';
2121
import * as PaymentMethods from '../../../../libs/actions/PaymentMethods';
22-
import getClickedElementLocation from '../../../../libs/getClickedElementLocation';
22+
import getClickedTargetLocation from '../../../../libs/getClickedTargetLocation';
2323
import withWindowDimensions from '../../../../components/withWindowDimensions';
2424
import CurrentWalletBalance from '../../../../components/CurrentWalletBalance';
2525
import ONYXKEYS from '../../../../ONYXKEYS';
@@ -90,7 +90,7 @@ class BasePaymentsPage extends React.Component {
9090
if (!this.state.addPaymentMethodButton) {
9191
return;
9292
}
93-
const buttonPosition = getClickedElementLocation(this.state.addPaymentMethodButton);
93+
const buttonPosition = getClickedTargetLocation(this.state.addPaymentMethodButton);
9494
this.setPositionAddPaymentMenu(buttonPosition);
9595
}
9696

@@ -129,9 +129,9 @@ class BasePaymentsPage extends React.Component {
129129
* @param {Boolean} isDefault
130130
*/
131131
paymentMethodPressed(nativeEvent, accountType, account, isDefault) {
132-
const position = getClickedElementLocation(nativeEvent);
132+
const position = getClickedTargetLocation(nativeEvent.currentTarget);
133133
this.setState({
134-
addPaymentMethodButton: nativeEvent,
134+
addPaymentMethodButton: nativeEvent.currentTarget,
135135
});
136136
if (accountType) {
137137
let formattedSelectedPaymentMethod;

0 commit comments

Comments
 (0)