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 2024-01-26] [$500] Emoji - When resizing the window, the open emoji picker moves to the LHN side #31155
Version Number: 1.3.97-0 Reproducible in staging?: Y Reproducible in production?: Y If this was caught during regression testing, add the test name, ID and link from TestRail: Email or phone of affected tester (no customers): Logs:https://stackoverflow.com/c/expensify/questions/4856 Expensify/Expensify Issue URL: Issue reported by: Applause - Internal Team Slack conversation:
changed the title [-]Emoji - When resizing the window, the open emoji picker moves to the LHN side[/-][+][$500] Emoji - When resizing the window, the open emoji picker moves to the LHN side[/+]on Nov 9, 2023
This happens because when we copy reference of anchor element and then measure it's position using measureInWindow the response of callback comes as (x, y, width, height) => (0, 0, 0, 0) when we resize the window horizontally.
And if we check the original anchor element's position using measure it's position is correct.
What changes do you think we should make in order to solve the problem?
First we create a useDimensionChange hook which will take a callback function and will call it whenever the dimension of the element changes.
then we move the calculate logic to a function onAnchorDimensionChange which takes the original ref and pass it to useImperativeHandle.
then we create a onAnchorDimensionChange function in EmojiPickerAction.ts and call it in useDimensionChange at each place where we use the showEmojiPicker function.
Below example is for EmojiPickerButton.js but we have to do the same for other places where we use showEmojiPicker function.
// `emojiPopoverAnchor.current` is the original ref of the anchor element from `EmojiPickerButton.js`useDimensionChange(()=>EmojiPickerAction.onAnchorDimensionChange(emojiPopoverAnchor.current));
Video for EmojiPickerButton.js
videoc8046c9e-f613-4550-b13f-b300ef68a079.mp4
What alternative solutions did you explore? (Optional)
Please re-state the problem that we are trying to solve in this issue.
When resizing the window, the open emoji picker moves to the LHN side
What is the root cause of that problem?
When we resize the window, the ref of the emoji button here will change, however, since we only passed the value (.current) of that ref here as the anchorRef, that anchorRef does not change and points to a non-existent component, leading to the dimensions become all 0 and the emoji picker moves to LHN side.
What changes do you think we should make in order to solve the problem?
The way we're passing refs as params to other components are not ideal, that way the original ref and the ref that we pass can get out of sync, causing issues like this one.
So the pattern that we use is usually:
Create and update the ref inside the anchor component (in this case, inside EmojiPickerButton)
Pass that ref to another component that displays the actual popover (in this case, the EmojiPicker)
We need to make sure they are always in sync, or ideally, always 1 single ref. We should create a new hook useSyncedRef that will return 1 ref for both components.
The problem is, that the x, y, w, and h returned from calculateAnchorPosition is 0.
This is because the element we want to measure (emojiPopoverAnchor.current) is not available on the dom anymore. emojiPopoverAnchor in this case is the emoji picker button.
The element becomes not available as soon as the emoji picker menu shows. Why?
The emoji picker button is wrapped with a PopoverAnchorTooltip.
When we first open the web, the emoji picker button is rendered with a tooltip, but when the emoji picker popover shows, we render the emoji picker button without a tooltip. This becomes a problem because if we render it with a tooltip, we clone the children (in this case the emoji picker button). So, both elements are different instances and the element that we pass to the EmojiPicker is the element of the with a tooltip.
What changes do you think we should make in order to solve the problem?
Instead of passing the element as the emojiPopoverAnchorValue to EmojiPicker, we should pass the ref object so we can always get the latest value from the ref object.
the first .current is to access the emojiPopoverAnchor ref object of EmojiPickerButton, and the second .current is to access the emojiPopoverAnchor element of EmojiPickerButton (the Pressable)
Last, we need to modify below code so it pass the correct ref to the popover
The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.27-1 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
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:
[@aimane-chnaif] The PR that introduced the bug has been identified. Link to the PR:
[@aimane-chnaif] 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:
[@aimane-chnaif] 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:
[@aimane-chnaif] Determine if we should create a regression test for this bug.
[@aimane-chnaif] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
[@lschurr] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:
changed the title [-][HOLD for payment 2024-01-26] [HOLD for payment 2024-01-04] [$500] Emoji - When resizing the window, the open emoji picker moves to the LHN side[/-][+][HOLD for payment 2024-01-26] [$500] Emoji - When resizing the window, the open emoji picker moves to the LHN side[/+]on Jan 19, 2024
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
Determine if we should create a regression test for this bug. This is kind of edge case and caught by QA team so no need regression test
If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
Activity
[-]Emoji - When resizing the window, the open emoji picker moves to the LHN side[/-][+][$500] Emoji - When resizing the window, the open emoji picker moves to the LHN side[/+]melvin-bot commentedon Nov 9, 2023
Triggered auto assignment to @lschurr (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.melvin-bot commentedon Nov 9, 2023
Job added to Upwork: https://www.upwork.com/jobs/~01b9e60337c2ef461a
melvin-bot commentedon Nov 9, 2023
Bug0 Triage Checklist (Main S/O)
Platformsin OP are ✅)melvin-bot commentedon Nov 9, 2023
Triggered auto assignment to Contributor-plus team member for initial proposal review - @aimane-chnaif (
External)jeet-dhandha commentedon Nov 9, 2023
Proposal
Please re-state the problem that we are trying to solve in this issue.
What is the root cause of that problem?
{horizontal: 0, vertical: 0}when we resize the window horizontally.App/src/components/EmojiPicker/EmojiPicker.js
Line 132 in e2c1c03
This happens because when we copy reference of anchor element and then measure it's position using
measureInWindowthe response of callback comes as (x, y, width, height) => (0, 0, 0, 0) when we resize the window horizontally.And if we check the original anchor element's position using
measureit's position is correct.What changes do you think we should make in order to solve the problem?
useDimensionChangehook which will take a callback function and will call it whenever the dimension of the element changes.onAnchorDimensionChangewhich takes the original ref and pass it touseImperativeHandle.App/src/components/EmojiPicker/EmojiPicker.js
Lines 124 to 135 in e2c1c03
onAnchorDimensionChangefunction inEmojiPickerAction.tsand call it inuseDimensionChangeat each place where we use theshowEmojiPickerfunction.Below example is for
EmojiPickerButton.jsbut we have to do the same for other places where we useshowEmojiPickerfunction.Video for EmojiPickerButton.js
video
c8046c9e-f613-4550-b13f-b300ef68a079.mp4
What alternative solutions did you explore? (Optional)
tienifr commentedon Nov 10, 2023
Proposal
Please re-state the problem that we are trying to solve in this issue.
When resizing the window, the open emoji picker moves to the LHN side
What is the root cause of that problem?
When we resize the window, the ref of the emoji button here will change, however, since we only passed the value (
.current) of that ref here as the anchorRef, that anchorRef does not change and points to a non-existent component, leading to the dimensions become all 0 and the emoji picker moves to LHN side.What changes do you think we should make in order to solve the problem?
The way we're passing refs as params to other components are not ideal, that way the original ref and the ref that we pass can get out of sync, causing issues like this one.
So the pattern that we use is usually:
EmojiPickerButton)EmojiPicker)useSyncedRefthat will return 1 ref for both components.And replace this
with
And we don't need to pass the ref from the
EmojiPickerButtontoEmojiPickerviashowEmojiPickerany more.What alternative solutions did you explore? (Optional)
We can just add another method
updateAnchorRefinsideEmojiPickerand call it whenever the ref is updated inEmojiPickerButtonAny place that has this issue can be fixed the same way by the main or alternative approach, but the main approach is global.
bernhardoj commentedon Nov 10, 2023
Proposal
Please re-state the problem that we are trying to solve in this issue.
Resizing the browser window moves the emoji picker to the left side of the screen.
What is the root cause of that problem?
In EmojiPicker, we have a dimension change listener to calculate a new position.
App/src/components/EmojiPicker/EmojiPicker.js
Lines 124 to 135 in d4a97bc
The problem is, that the x, y, w, and h returned from
calculateAnchorPositionis 0.This is because the element we want to measure (
emojiPopoverAnchor.current) is not available on the dom anymore.emojiPopoverAnchorin this case is the emoji picker button.The element becomes not available as soon as the emoji picker menu shows. Why?
The emoji picker button is wrapped with a PopoverAnchorTooltip.
App/src/components/EmojiPicker/EmojiPickerButton.js
Lines 38 to 40 in d4a97bc
PopoverAnchorTooltip will conditionally render the element with/without a tooltip based on the popover visibility.
App/src/components/Tooltip/PopoverAnchorTooltip.js
Lines 40 to 52 in d4a97bc
When we first open the web, the emoji picker button is rendered with a tooltip, but when the emoji picker popover shows, we render the emoji picker button without a tooltip. This becomes a problem because if we render it with a tooltip, we clone the children (in this case the emoji picker button). So, both elements are different instances and the element that we pass to the EmojiPicker is the element of the with a tooltip.
App/src/components/EmojiPicker/EmojiPickerButton.js
Line 45 in 358e4b1
What changes do you think we should make in order to solve the problem?
Instead of passing the element as the
emojiPopoverAnchorValueto EmojiPicker, we should pass therefobject so we can always get the latest value from the ref object.We should make the above changes to every usage of EmojiPickerAction.showEmojiPicker
Then, we need to modify EmojiPicker so it works with the ref, that is by accessing the element by using double
.current.App/src/components/EmojiPicker/EmojiPicker.js
Lines 51 to 58 in 358e4b1
App/src/components/EmojiPicker/EmojiPicker.js
Lines 125 to 132 in 358e4b1
the first .current is to access the
emojiPopoverAnchorref object of EmojiPickerButton, and the second .current is to access theemojiPopoverAnchorelement of EmojiPickerButton (the Pressable)Last, we need to modify below code so it pass the correct ref to the popover
App/src/components/EmojiPicker/EmojiPicker.js
Line 157 in 358e4b1
132 remaining items
melvin-bot commentedon Jan 19, 2024
Reviewinglabel has been removed, please complete the "BugZero Checklist".melvin-bot commentedon Jan 19, 2024
The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.27-1 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
If no regressions arise, payment will be issued on 2024-01-26. 🎊
For reference, here are some details about the assignees on this issue:
melvin-bot commentedon Jan 19, 2024
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:
[-][HOLD for payment 2024-01-26] [HOLD for payment 2024-01-04] [$500] Emoji - When resizing the window, the open emoji picker moves to the LHN side[/-][+][HOLD for payment 2024-01-26] [$500] Emoji - When resizing the window, the open emoji picker moves to the LHN side[/+]lschurr commentedon Jan 25, 2024
@aimane-chnaif - Can you work through the checklist on this one?
aimane-chnaif commentedon Jan 25, 2024
lschurr commentedon Jan 29, 2024
It looks like the automation didn't work here. Moving to Daily and will handle payments shortly.
lschurr commentedon Jan 30, 2024
Payment summary:
lschurr commentedon Jan 30, 2024
Offers sent in Upwork.
aimane-chnaif commentedon Jan 30, 2024
Offer accepted already - #31155 (comment)
lschurr commentedon Jan 30, 2024
Ah, sorry about that! I'll use the previous offers.
lschurr commentedon Jan 30, 2024
Payments issued. Closing this one out.