From 7b3468598b7d1fbb246b684fc7f6799d17ff1016 Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Thu, 17 Aug 2023 01:42:28 +0530 Subject: [PATCH 1/8] fix non-toggle popover to toggle --- src/components/ButtonWithDropdownMenu.js | 2 +- src/components/ThreeDotsMenu/index.js | 4 ++++ src/pages/settings/Payments/PaymentsPage/BasePaymentsPage.js | 5 +++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/components/ButtonWithDropdownMenu.js b/src/components/ButtonWithDropdownMenu.js index 5c1a95b8755..0246b93ea03 100644 --- a/src/components/ButtonWithDropdownMenu.js +++ b/src/components/ButtonWithDropdownMenu.js @@ -104,7 +104,7 @@ function ButtonWithDropdownMenu(props) { success isDisabled={props.isDisabled} style={[styles.pl0]} - onPress={() => setIsMenuVisible(true)} + onPress={() => setIsMenuVisible(!isMenuVisible)} shouldRemoveLeftBorderRadius > { + if (this.state.isPopupMenuVisible) { + this.hidePopoverMenu(); + return; + } this.showPopoverMenu(); if (this.props.onIconPress) { this.props.onIconPress(); diff --git a/src/pages/settings/Payments/PaymentsPage/BasePaymentsPage.js b/src/pages/settings/Payments/PaymentsPage/BasePaymentsPage.js index 359809dda0f..5b82ce24ab8 100644 --- a/src/pages/settings/Payments/PaymentsPage/BasePaymentsPage.js +++ b/src/pages/settings/Payments/PaymentsPage/BasePaymentsPage.js @@ -128,6 +128,11 @@ function BasePaymentsPage(props) { * @param {String|Number} methodID */ const paymentMethodPressed = (nativeEvent, accountType, account, isDefault, methodID) => { + if (shouldShowAddPaymentMenu) { + setShouldShowAddPaymentMenu(false); + return; + } + paymentMethodButtonRef.current = nativeEvent.currentTarget; // The delete/default menu From 1f0d557b80a91b8cdb49ffd3cff43d7039b63691 Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Thu, 17 Aug 2023 20:47:29 +0530 Subject: [PATCH 2/8] fix toggle for addpayment method in BaseKycwall --- src/components/KYCWall/BaseKYCWall.js | 12 +++++++++--- .../Payments/PaymentsPage/BasePaymentsPage.js | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/components/KYCWall/BaseKYCWall.js b/src/components/KYCWall/BaseKYCWall.js index 534f00b7f74..f483ef18205 100644 --- a/src/components/KYCWall/BaseKYCWall.js +++ b/src/components/KYCWall/BaseKYCWall.js @@ -95,6 +95,9 @@ class KYCWall extends React.Component { * @param {String} iouPaymentType */ continue(event, iouPaymentType) { + if (this.state.shouldShowAddPaymentMenu) { + return; + } this.setState({transferBalanceButton: event.nativeEvent.target}); const isExpenseReport = ReportUtils.isExpenseReport(this.props.iouReport); const paymentCardList = this.props.fundList || this.props.cardList || {}; @@ -113,7 +116,6 @@ class KYCWall extends React.Component { }); return; } - if (!isExpenseReport) { // Ask the user to upgrade to a gold wallet as this means they have not yet gone through our Know Your Customer (KYC) checks const hasGoldWallet = this.props.userWallet.tierName && this.props.userWallet.tierName === CONST.WALLET.TIER_NAME.GOLD; @@ -123,7 +125,6 @@ class KYCWall extends React.Component { return; } } - Log.info('[KYC Wallet] User has valid payment method and passed KYC checks or did not need them'); this.props.onSuccessfulKYC(iouPaymentType); } @@ -133,7 +134,12 @@ class KYCWall extends React.Component { <> this.setState({shouldShowAddPaymentMenu: false})} + onClose={() => { + /* a small delay will schedule this to run after the continue method preventing rerendering of the menu when clicking the menu item */ + setTimeout(() => { + this.setState({shouldShowAddPaymentMenu: false}); + }, 10); + }} anchorPosition={{ vertical: this.state.anchorPositionVertical, horizontal: this.state.anchorPositionHorizontal, diff --git a/src/pages/settings/Payments/PaymentsPage/BasePaymentsPage.js b/src/pages/settings/Payments/PaymentsPage/BasePaymentsPage.js index 5b82ce24ab8..258818a18e3 100644 --- a/src/pages/settings/Payments/PaymentsPage/BasePaymentsPage.js +++ b/src/pages/settings/Payments/PaymentsPage/BasePaymentsPage.js @@ -292,7 +292,7 @@ function BasePaymentsPage(props) { )} - {props.userWallet.currentBalance > 0 && ( + {props.userWallet.currentBalance === 0 && ( Date: Thu, 17 Aug 2023 23:21:11 +0530 Subject: [PATCH 3/8] code formatting --- src/components/ThreeDotsMenu/index.js | 6 +++--- .../settings/Payments/PaymentsPage/BasePaymentsPage.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/ThreeDotsMenu/index.js b/src/components/ThreeDotsMenu/index.js index 8cb1bc91aa4..abed05b4438 100644 --- a/src/components/ThreeDotsMenu/index.js +++ b/src/components/ThreeDotsMenu/index.js @@ -78,9 +78,9 @@ function ThreeDotsMenu({iconTooltip, icon, iconFill, iconStyles, onIconPress, me { - if (isPopupMenuVisible) { - hidePopoverMenu(); - return; + if (isPopupMenuVisible) { + hidePopoverMenu(); + return; } showPopoverMenu(); if (onIconPress) { diff --git a/src/pages/settings/Payments/PaymentsPage/BasePaymentsPage.js b/src/pages/settings/Payments/PaymentsPage/BasePaymentsPage.js index 258818a18e3..5b82ce24ab8 100644 --- a/src/pages/settings/Payments/PaymentsPage/BasePaymentsPage.js +++ b/src/pages/settings/Payments/PaymentsPage/BasePaymentsPage.js @@ -292,7 +292,7 @@ function BasePaymentsPage(props) { )} - {props.userWallet.currentBalance === 0 && ( + {props.userWallet.currentBalance > 0 && ( Date: Fri, 18 Aug 2023 18:37:44 +0530 Subject: [PATCH 4/8] resolve merge conflicts and requested changes --- src/components/ButtonWithDropdownMenu.js | 3 +++ src/components/KYCWall/BaseKYCWall.js | 5 ++++- src/components/SettlementButton.js | 3 ++- src/components/ThreeDotsMenu/index.js | 2 ++ src/pages/settings/Wallet/WalletPage/BaseWalletPage.js | 3 ++- 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/components/ButtonWithDropdownMenu.js b/src/components/ButtonWithDropdownMenu.js index 0246b93ea03..c1959c41e70 100644 --- a/src/components/ButtonWithDropdownMenu.js +++ b/src/components/ButtonWithDropdownMenu.js @@ -45,6 +45,7 @@ const propTypes = { horizontal: PropTypes.oneOf(_.values(CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL)), vertical: PropTypes.oneOf(_.values(CONST.MODAL.ANCHOR_ORIGIN_VERTICAL)), }), + buttonRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), }; const defaultProps = { @@ -56,6 +57,7 @@ const defaultProps = { horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.RIGHT, vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.TOP, // we assume that popover menu opens below the button, anchor is at TOP }, + buttonRef: () => {}, }; function ButtonWithDropdownMenu(props) { @@ -90,6 +92,7 @@ function ButtonWithDropdownMenu(props) {