Open lanitochka17 opened 10 hours ago
Triggered auto assignment to @jliexpensify (Bug
), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.
@jliexpensify FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors
@Expensify/design hello, is this a bug? I feel like it might be, as we're automatically moving it - but it could also be intentional, to get the picker out of the way as the window is now reduced. Keen for your thoughts, cheers!
Yeah I would expect this to keep it's positioned anchored to the button that triggered it
Job added to Upwork: https://www.upwork.com/jobs/~021848576183089723860
Triggered auto assignment to Contributor-plus team member for initial proposal review - @abdulrahuman5196 (External
)
Edited by proposal-police: This proposal was edited at 2024-10-22 04:18:12 UTC.
The emoji picker is moved to the top left when resizing window.
In the emoji picker component, we already have a dimension listener to recalculate the position. https://github.com/Expensify/App/blob/ac57d30444f5ed2bf0be3bc72705e0da64faa03e/src/components/EmojiPicker/EmojiPicker.tsx#L164-L173
However, the value returned is always 0 (-14 for top for me). The reason is, everytime we resize the window, the emoji picker button (which is the anchor where we calculate the position based on) is always re-rendered. https://github.com/Expensify/App/blob/ac57d30444f5ed2bf0be3bc72705e0da64faa03e/src/components/EmojiPicker/EmojiPickerButton.tsx#L33-L45
I verified this by appending a random number to the ID and it keeps changing when resizing. This causes the PopoverAnchorTooltip to also re-rendered and isPopoverRelatedToTooltipOpen
is recalculated on every render (react-compiler wrongly optimize it) which will return false
because tooltipNode
is undefined which will remount the button whenever isPopoverRelatedToTooltipOpen
is changed.
https://github.com/Expensify/App/blob/7111c19f641bade5330116336e09f923be0fa80d/src/components/Tooltip/PopoverAnchorTooltip.tsx#L7-L35
So, when we are trying to recalculate the new position, the previous ref is not "valid" anymore. The emoji picker button keeps getting re-rendered because we pass inline function to the props. https://github.com/Expensify/App/blob/ac57d30444f5ed2bf0be3bc72705e0da64faa03e/src/pages/home/report/ReportActionCompose/ReportActionCompose.tsx#L518-L528
So, when the ReportActionCompose is re-rendered because of the window size, the emoji picker button is also re-rendered.
Wrap both function to a useCallback
so it only re-renders when it's really need to.
https://github.com/Expensify/App/blob/ac57d30444f5ed2bf0be3bc72705e0da64faa03e/src/pages/home/report/ReportActionCompose/ReportActionCompose.tsx#L518-L528
And the focus
function here too because onModalHide
depends on it.
https://github.com/Expensify/App/blob/ac57d30444f5ed2bf0be3bc72705e0da64faa03e/src/pages/home/report/ReportActionCompose/ReportActionCompose.tsx#L203-L209
We need to apply this to other usage of emoji picker too, for example, in edit composer.
If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!
Version Number: 9.0.51-2 Reproducible in staging?: Y Reproducible in production?: Y If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: N/A If this was caught during regression testing, add the test name, ID and link from TestRail: N/A Email or phone of affected tester (no customers): dave0123seife@gmail.com Issue reported by: Applause - Internal Team
Action Performed:
1, Navigate to any chat
Expected Result:
Emoji picker stays in its position
Actual Result:
Reducing the size of the windows cause the Emoji picker to be moved to the top
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Screenshots/Videos
Add any screenshot/video evidence
https://github.com/user-attachments/assets/c1f0ebb0-e5c5-4820-ab2b-e07c70324a7d
View all open jobs on GitHub
Upwork Automation - Do Not Edit
Issue Owner
Current Issue Owner: @abdulrahuman5196