-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Fix popover position for payment buttons #28744
Changes from 2 commits
ccd1b31
e5652b6
46c3045
5b7f439
3ba03d1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -62,9 +62,9 @@ class KYCWall extends React.Component { | |||||||||
* @returns {Object} | ||||||||||
*/ | ||||||||||
getAnchorPosition(domRect) { | ||||||||||
if (this.props.popoverPlacement === 'bottom') { | ||||||||||
if (this.props.anchorAlignment.vertical === CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.TOP) { | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. explanation here - App/src/components/ButtonWithDropdownMenu.js Lines 91 to 94 in f77a5a5
|
||||||||||
return { | ||||||||||
anchorPositionVertical: domRect.top + (domRect.height - 2), | ||||||||||
anchorPositionVertical: domRect.top + domRect.height + CONST.MODAL.POPOVER_MENU_PADDING, | ||||||||||
anchorPositionHorizontal: domRect.left + 20, | ||||||||||
}; | ||||||||||
} | ||||||||||
|
@@ -92,15 +92,15 @@ class KYCWall extends React.Component { | |||||||||
* If they do have a valid payment method they are navigated to the "enable payments" route to complete KYC checks. | ||||||||||
* If they are already KYC'd we will continue whatever action is gated behind the KYC wall. | ||||||||||
* | ||||||||||
* @param {Event} event | ||||||||||
* @param {Event} _event | ||||||||||
* @param {String} iouPaymentType | ||||||||||
*/ | ||||||||||
continue(event, iouPaymentType) { | ||||||||||
continue(_event, iouPaymentType) { | ||||||||||
if (this.state.shouldShowAddPaymentMenu) { | ||||||||||
this.setState({shouldShowAddPaymentMenu: false}); | ||||||||||
return; | ||||||||||
} | ||||||||||
this.setState({transferBalanceButton: event.nativeEvent.target}); | ||||||||||
this.setState({transferBalanceButton: this.anchorRef.current}); | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was required for Screen.Recording.2023-10-04.at.1.42.55.AM.mov |
||||||||||
const isExpenseReport = ReportUtils.isExpenseReport(this.props.iouReport); | ||||||||||
const paymentCardList = this.props.fundList || {}; | ||||||||||
|
||||||||||
|
@@ -110,7 +110,7 @@ class KYCWall extends React.Component { | |||||||||
(!isExpenseReport && !PaymentUtils.hasExpensifyPaymentMethod(paymentCardList, this.props.bankAccountList)) | ||||||||||
) { | ||||||||||
Log.info('[KYC Wallet] User does not have valid payment method'); | ||||||||||
const clickedElementLocation = getClickedTargetLocation(event.nativeEvent.target); | ||||||||||
const clickedElementLocation = getClickedTargetLocation(this.anchorRef.current); | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @aimane-chnaif if you want we can keep it as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's do that for safety There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we apply the change for safety here and also above? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @aimane-chnaif @marcochavezf done. |
||||||||||
const position = this.getAnchorPosition(clickedElementLocation); | ||||||||||
this.setPositionAddPaymentMenu(position); | ||||||||||
this.setState({ | ||||||||||
|
@@ -142,6 +142,7 @@ class KYCWall extends React.Component { | |||||||||
vertical: this.state.anchorPositionVertical, | ||||||||||
horizontal: this.state.anchorPositionHorizontal, | ||||||||||
}} | ||||||||||
anchorAlignment={this.props.anchorAlignment} | ||||||||||
onItemSelected={(item) => { | ||||||||||
this.setState({shouldShowAddPaymentMenu: false}); | ||||||||||
if (item === CONST.PAYMENT_METHODS.BANK_ACCOUNT) { | ||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -107,6 +107,10 @@ function MoneyReportHeader({session, personalDetails, policy, chatReport, report | |
shouldShowPaymentOptions | ||
style={[styles.pv2]} | ||
formattedAmount={formattedAmount} | ||
anchorAlignment={{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In header button, popover should open below button (anchor should be at top) |
||
horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.LEFT, | ||
vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.TOP, | ||
}} | ||
/> | ||
</View> | ||
)} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -230,6 +230,10 @@ function ReportPreview(props) { | |
enablePaymentsRoute={ROUTES.ENABLE_PAYMENTS} | ||
addBankAccountRoute={bankAccountRoute} | ||
style={[styles.requestPreviewBox]} | ||
anchorAlignment={{ | ||
horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.LEFT, | ||
vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.BOTTOM, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In ReportPreview, popover should open above button so anchor is bottom. |
||
}} | ||
/> | ||
)} | ||
</View> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -268,7 +268,10 @@ function BaseWalletPage(props) { | |
enablePaymentsRoute={ROUTES.SETTINGS_ENABLE_PAYMENTS} | ||
addBankAccountRoute={ROUTES.SETTINGS_ADD_BANK_ACCOUNT} | ||
addDebitCardRoute={ROUTES.SETTINGS_ADD_DEBIT_CARD} | ||
popoverPlacement="bottom" | ||
anchorAlignment={{ | ||
horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.LEFT, | ||
vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.TOP, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. popover should open below button, so vertical anchor position is top. |
||
}} | ||
> | ||
{(triggerKYCFlow, buttonRef) => ( | ||
<MenuItem | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aimane-chnaif I added this to fix this bug because I also found it during testing.