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] |
| ) : ( | ||
| <Button | ||
| success | ||
| ref={props.buttonRef} |
There was a problem hiding this comment.
@aimane-chnaif I added this to fix this bug because I also found it during testing.
| return; | ||
| } | ||
| this.setState({transferBalanceButton: event.nativeEvent.target}); | ||
| this.setState({transferBalanceButton: this.anchorRef.current}); |
There was a problem hiding this comment.
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
| shouldShowPaymentOptions | ||
| style={[styles.pv2]} | ||
| formattedAmount={formattedAmount} | ||
| anchorAlignment={{ |
There was a problem hiding this comment.
In header button, popover should open below button (anchor should be at top)
| 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.
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.
popover should open below button, so vertical anchor position is top.
| */ | ||
| 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.
explanation here -
App/src/components/ButtonWithDropdownMenu.js
Lines 91 to 94 in f77a5a5
|
@aimane-chnaif PR is ready for review. |
| ) { | ||
| 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.
@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.
Let's do that for safety
There was a problem hiding this comment.
Can we apply the change for safety here and also above?
|
@aimane-chnaif let me know if you have any suggestions. |
aimane-chnaif
left a comment
There was a problem hiding this comment.
Thanks for the detailed explanations per each line change
| ) { | ||
| 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.
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 |
| ) { | ||
| 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.
Can we apply the change for safety here and also above?
|
@marcochavezf I have applied the suggested changes. |
| 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.
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 Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodWaiting for Copylabel for a copy review on the original GH to get the correct copy.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.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