-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Fix popover position for payment buttons #28744
Conversation
@aimane-chnaif Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
@@ -143,6 +143,7 @@ function ButtonWithDropdownMenu(props) { | |||
) : ( | |||
<Button | |||
success | |||
ref={props.buttonRef} |
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.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
This was required for BaseWalletPage
, as transfer balance button contains multiple clickable items so if we used event.nativeEvent.target
the popover position used to differ slightly based on where we clicked. See video to see the bug -
Screen.Recording.2023-10-04.at.1.42.55.AM.mov
@@ -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 comment
The 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)
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
In ReportPreview, popover should open above button so anchor is bottom.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
popover should open below button, so vertical anchor position is top.
@@ -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 comment
The 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
props.anchorAlignment.vertical === CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.TOP | |
? y + h + CONST.MODAL.POPOVER_MENU_PADDING // if vertical anchorAlignment is TOP, menu will open below the button and we need to add the height of button and padding | |
: y - CONST.MODAL.POPOVER_MENU_PADDING, // if it is BOTTOM, menu will open above the button so NO need to add height but DO subtract padding | |
}); |
@aimane-chnaif PR is ready for review. |
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
@aimane-chnaif if you want we can keep it as this.anchorRef.current || event.nativeEvent.target
to be on the safer side. Same for usage above.
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.
Let's do that for safety
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.
Can we apply the change for safety here and also above?
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 @marcochavezf done.
@aimane-chnaif let me know if you have any suggestions. |
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.
Thanks for the detailed explanations per each line change
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
Let's do that for safety
Step 3 doesn't work for me Screen.Recording.2023-10-05.at.11.23.56.AM.mov |
@aimane-chnaif do you mean that the fix doesn't work for you? |
yes, as you see my video. I tested this branch after pulling main locally |
@Nikhil-Vats you reproduced and working on fix, right? |
@aimane-chnaif can you please try again once? I just tested and it works for me. It was working for me before as well as I attached the test videos on all platforms and there was no merge with main either. fix.mp4 |
@Nikhil-Vats did you test after merging latest main? |
@aimane-chnaif I did not merge latest main as there is no conflict. Should I do it? |
yes you should |
@aimane-chnaif It works after merging too, can you please recheck once? Screen.Recording.2023-10-05.at.7.23.04.PM.mov |
I did not some weird with other bugs (before merge too) -
Let me know if you face them too and I will create bug reports for them. |
still pull main and push to this branch |
Make sure that you don't have any new commits not pushed. Bug is still not fixed on this branch |
@aimane-chnaif I have just pushed after merging with latest main. Can you test again? |
Works fine now. Not sure what was wrong |
Let's leave this popover position at bottom Screen.Recording.2023-10-05.at.4.51.34.PM.mov |
Reviewer Checklist
Screenshots/VideosWebweb.movMobile Web - Chromemchrome.movMobile Web - Safarimsafari.movDesktopdesktop.moviOSios.movAndroid |
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.
LGTM 🎉
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
Can we apply the change for safety here and also above?
@marcochavezf I have applied the suggested changes. |
@@ -100,7 +100,8 @@ class KYCWall extends React.Component { | |||
this.setState({shouldShowAddPaymentMenu: false}); | |||
return; | |||
} | |||
this.setState({transferBalanceButton: event.nativeEvent.target}); | |||
const targetElement = this.anchorRef.current || event.nativeEvent.target; // safety check - use target from event if anchorRef is null |
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.
Let's add the comment above the code
const targetElement = this.anchorRef.current || event.nativeEvent.target; // safety check - use target from event if anchorRef is null | |
// Use event target as fallback if anchorRef is null for safety | |
const targetElement = this.anchorRef.current || event.nativeEvent.target; |
Done @marcochavezf |
Fixed @marcochavezf |
Don't know why it hasn't marked the suggestion as outdated but I added an empty line, check here |
LGTM, thanks guys! |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/marcochavezf in version: 1.3.79-0 🚀
|
@marcochavezf @aimane-chnaif Step 4 is failing. We have silver wallet accounts only. I remember it requires gold wallet for "transfer balance" to appear. Could you confirm? |
Correct. |
@aimane-chnaif , this will be validated internally?
|
I think you can skip that case if you're not able to test easily. web.mov |
🚀 Deployed to production by https://github.com/jasperhuangg in version: 1.3.79-5 🚀
|
🚀 Deployed to production by https://github.com/jasperhuangg in version: 1.3.79-5 🚀
|
🚀 Deployed to production by https://github.com/jasperhuangg in version: 1.3.79-5 🚀
|
Details
Fixed Issues
$ #26070
PROPOSAL: #26070 (comment)
Tests
You can test this using 2 of your accounts or you can also create a new workspace with only 1 member (logged in user) and request money. As you are the only member, request money button will be visible.
Use 2 of your accounts for testing. Login with account 1, request money in the chat by going to chat with account 2 > click on + button > Request money > Enter details and click on request money button. Afterwards login with account 2 and follow the steps below -
In the chat, click the pay button in Report Preview. The popover should open above the button.
See screenshot to see what it should look like.
Now, click on the report preview and in the header try clicking on the caret (dropdown icon) and the main button and make sure both popovers open below the button.
See video to see what it should look like.
Screen.Recording.2023-10-04.at.1.30.43.AM.mov
Now, go to settings > wallet. Click on transfer balance and verify that the popover opens below the transfer balance button.
See video to see what it should look like.
Screen.Recording.2023-10-04.at.1.32.07.AM.mov
Offline tests
Same as above.
QA Steps
Same as above.
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Web
26070_web.mp4
Mobile Web - Chrome
26070_mweb_chrome.mp4
Mobile Web - Safari
26070_mweb_safari.mp4
Desktop
26070_desktop.mp4
iOS
26070_ios.mp4
Android
26070_android.mp4