You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[HOLD for payment 2023-11-21] [$500] Wrong position of payment method dropdown menu #31069
The issue occurs because .measureInWindow method used here is giving incorrect pos. values after the RNW upgrade, i believe the bug is upstream and not related to our codebase
Changes Suggested
we should follow the same pattern for setting position like we are using in BaseKYCWall i.e. using getClickedTargetLocation like below:
? 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
});
});
This works fine but it gives a wrong position inside the inverted flat list. In inverted FlatList, -1 of scale is applied and measureInWindow gives the scaled result(Refer https://reactnative.dev/docs/flatlist#inverted). This looks like come from the recent change of react-native-web in this PR
Scaled measurement returns: This is the root cause
What changes do you think we should make in order to solve the problem?
We can simply make a upstream patch
Add the following patch to the current patch
diff --git a/node_modules/react-native-web/dist/exports/UIManager/index.js b/node_modules/react-native-web/dist/exports/UIManager/index.js
index 15b71d5..46b9e01 100644
--- a/node_modules/react-native-web/dist/exports/UIManager/index.js
+++ b/node_modules/react-native-web/dist/exports/UIManager/index.js
@@ -77,7 +77,7 @@ var UIManager = {
measureInWindow(node, callback) {
if (node) {
setTimeout(() => {
- var _getRect2 = getRect(node),
+ var _getRect2 = node.getBoundingClientRect(),
height = _getRect2.height,
left = _getRect2.left,
top = _getRect2.top,
This works as expected
Result
What alternative solutions did you explore? (Optional)
We need to take this scaled result into consideration
caretButton.current.measureInWindow((x, y, w, h) => {
const horizontal = x + w;
const vertical = props.shouldInvertMeasurement ? windowHeight - y + 18 : y; // weird offset in inverted mode
setPopoverAnchorPosition({
horizontal,
vertical: props.anchorAlignment.vertical === CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.TOP
? vertical + 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
: vertical - 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
});
});
Add shouldInvertMeasurement props with value truehere in ReportPreview component
This works fine but it gives a wrong position inside the inverted flat list. In inverted FlatList, -1 of scale is applied and measureInWindow gives the scaled result
I am fine applying patch for now to fix deploy blocker but we should fix the real root cause for sure. @getusha do you think this solution makes sense?
- var _getRect2 = getRect(node),+ var _getRect2 = node.getBoundingClientRect(),
@s-alves10 @situchan probably adding shouldUseTargetLocation prop to PopoverWithMeasuredContent will solve this issue because we added that for this kind of issue. i am not sure if it will be accurate might need a slight touch.
@situchan thanks, I had missed that. Noting for my future self: I see you listed as a reviewer for the PR that caused this regression but that's from comments made two days ago, so are not relevant to this issue and don't change payment
changed the title [-][HOLD for payment 2023-11-21] [HOLD for payment 2023-11-17] [$500] Wrong position of payment method dropdown menu[/-][+][HOLD for payment 2023-11-21] [$500] Wrong position of payment method dropdown menu[/+]on Nov 23, 2023
BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:
[@getusha] The PR that introduced the bug has been identified. Link to the PR: N/A this is a bug from react-native-web introduced after upgrading to latest release.
[@getusha] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment: N/A
[@getusha] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion: N/A
[@getusha] Determine if we should create a regression test for this bug. No this a minor bug and react-native-web issue.
Activity
melvin-bot commentedon Nov 8, 2023
Triggered auto assignment to @conorpendergrast (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.melvin-bot commentedon Nov 8, 2023
Bug0 Triage Checklist (Main S/O)
Platformsin OP are ✅)ishpaul777 commentedon Nov 8, 2023
Proposal
Problem
Wrong position of payment method dropdown menu
Root Cause
The issue occurs because
.measureInWindowmethod used here is giving incorrect pos. values after the RNW upgrade, i believe the bug is upstream and not related to our codebaseChanges Suggested
we should follow the same pattern for setting position like we are using in
BaseKYCWalli.e. usinggetClickedTargetLocationlike below:dummy-1111 commentedon Nov 9, 2023
Proposal
Please re-state the problem that we are trying to solve in this issue.
Popover menu of payment method dropdown button is shown at the wrong position
What is the root cause of that problem?
We measure the anchor position of the popover menu below
App/src/components/ButtonWithDropdownMenu.js
Lines 91 to 99 in 3f2de5c
This works fine but it gives a wrong position inside the inverted flat list. In inverted
FlatList, -1 of scale is applied and measureInWindow gives the scaled result(Refer https://reactnative.dev/docs/flatlist#inverted). This looks like come from the recent change ofreact-native-webin this PRScaled measurement returns: This is the root cause
What changes do you think we should make in order to solve the problem?
We can simply make a upstream patch
Add the following patch to the current patch
This works as expected
Result
What alternative solutions did you explore? (Optional)
We need to take this scaled result into consideration
shouldInvertMeasurementwith default valuefalseto the ButtonWithDropdownMenu and SettlementButton componentsshouldInvertMeasurementprops with valuetruehere inReportPreviewcomponentdummy-1111 commentedon Nov 9, 2023
This is reproducible in staging, and not in production. Can be a deploy blocker
cc @m-natarajan @conorpendergrast
situchan commentedon Nov 9, 2023
@s-alves10 Scanning code in RNW upgrade, I don't see any change in UIManager.
situchan commentedon Nov 9, 2023
Why used to work before RNW upgrade?
situchan commentedon Nov 9, 2023
I am fine applying patch for now to fix deploy blocker but we should fix the real root cause for sure.
@getusha do you think this solution makes sense?
dummy-1111 commentedon Nov 9, 2023
I debugged the RNW and
getRectfunction in UIManager returns the wrong result for inverted FlatList. In the previous version, it works finedummy-1111 commentedon Nov 9, 2023
The
getBoundingClientRectmethod returns the size of an element and its position relative to the viewport.getusha commentedon Nov 9, 2023
@s-alves10 @situchan probably adding
shouldUseTargetLocationprop toPopoverWithMeasuredContentwill solve this issue because we added that for this kind of issue. i am not sure if it will be accurate might need a slight touch.67 remaining items
conorpendergrast commentedon Nov 23, 2023
Looks like this didn't get switched to Daily, and it's due payment!
conorpendergrast commentedon Nov 23, 2023
Payouts due:
Issue Reporter AND PR reviewer: $50 + $500 = $550 @situchan requires payment offer
Contributor+: N/A @getusha - regression
Contributor: $500 @s-alves10 requires payment offer
Upwork job is here.
situchan commentedon Nov 23, 2023
I also reviewed PR
conorpendergrast commentedon Nov 23, 2023
@situchan thanks, I had missed that. Noting for my future self: I see you listed as a reviewer for the PR that caused this regression but that's from comments made two days ago, so are not relevant to this issue and don't change payment
conorpendergrast commentedon Nov 23, 2023
@s-alves10 please accept the offer!
conorpendergrast commentedon Nov 23, 2023
@getusha Can you do the C+ checklist too, please? Thank you!
[-][HOLD for payment 2023-11-21] [HOLD for payment 2023-11-17] [$500] Wrong position of payment method dropdown menu[/-][+][HOLD for payment 2023-11-21] [$500] Wrong position of payment method dropdown menu[/+]dummy-1111 commentedon Nov 23, 2023
@conorpendergrast
Offer accepted, thanks
getusha commentedon Nov 24, 2023
@s-alves10 any updates on the upstream PR & issue? i am sure we shouldn't be ignoring that.
dummy-1111 commentedon Nov 24, 2023
https://expensify.slack.com/archives/C01GTK53T8Q/p1700803705123509?thread_ts=1699611327.310029&cid=C01GTK53T8Q
conorpendergrast commentedon Nov 24, 2023
Paid! Just the C+ checklist now
getusha commentedon Nov 24, 2023
BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:
react-native-webintroduced after upgrading to latest release.conorpendergrast commentedon Nov 24, 2023
Nice! All done, thank you everyone