Repository navigation
Closed
Labels
BugSomething is broken. Auto assigns a BugZero manager.Something is broken. Auto assigns a BugZero manager.DailyKSv2KSv2ExternalAdded to denote the issue can be worked on by a contributorAdded to denote the issue can be worked on by a contributorHelp WantedApply this label when an issue is open to proposals by contributorsApply this label when an issue is open to proposals by contributors
Description
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: v9.3.59-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #87394
Email or phone of affected tester (no customers): testpayment935@gmail.com
Issue reported by: Applause Internal Team
Bug source: Pull Request QA execution
Device used: Windows 11 pro /Chrome
App Component: Chat Report View
Action Performed:
- Navigate to staging.new.expensify.com
- Open any chat → click emoji picker button
- On web, resize the browser while emoji picker is open using device tool bar
- Try this multiple times
- In resized view, click the emoji picker
- Notice it is not displayed
- Click device tool bar in order to see the web view
- Notice the emoji picker is already shown
- Click device tool bar in order to see the mobile view
- Notice the repositioned emoji picker is shown
Expected Result:
The emoji picker should repositions correctly
Actual Result:
- In step 4, repositioned emoji picker is not constantly shown
- in step 5-10, the emojis are not shown when clicking the emoji picker until resized again
Workaround:
Unknown
Platforms:
- Android: App
- Android: mWeb Chrome
- iOS: App
- iOS: mWeb Safari
- iOS: mWeb Chrome
- Windows: Chrome
- MacOS: Chrome / Safari
Screenshots/Videos
Bug7129170_1776120380452.bandicam_2026-04-14_01-31-13-516.mp4
Issue Owner
Current Issue Owner: @abdulrahuman5196Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~022043831658429963643
- Upwork Job ID: 2043831658429963643
- Last Price Increase: 2026-04-27
Metadata
Metadata
Assignees
Labels
BugSomething is broken. Auto assigns a BugZero manager.Something is broken. Auto assigns a BugZero manager.DailyKSv2KSv2ExternalAdded to denote the issue can be worked on by a contributorAdded to denote the issue can be worked on by a contributorHelp WantedApply this label when an issue is open to proposals by contributorsApply this label when an issue is open to proposals by contributors
Type
Projects
- StatusShow more project fieldsDone
Activity
MelvinBot commentedon Apr 13, 2026
Proposal
Problem
The emoji picker fails to display or reposition correctly when the browser window is resized across the mobile/desktop breakpoint (800px), particularly when toggling Chrome DevTools device toolbar.
Solution
The root cause is a stale closure in the
Dimensions.addEventListener('change')handler atsrc/components/EmojiPicker/EmojiPicker.tsx:209-236.When a resize crosses the 800px breakpoint, the Dimensions
changeevent fires before React re-renders with the updatedshouldUseNarrowLayoutvalue. The handler captures the stale pre-resize value:shouldUseNarrowLayoutis stillfalsein the closure. If the anchor ref is null (which happens becauseEmojiPickerButtonunmounts during layout shift and nulls the ref via cleanup), the conditionisEmojiPickerVisible && !shouldUseNarrowLayoutis true →hideEmojiPicker()is called, making the picker disappear.shouldUseNarrowLayoutis stilltruein the closure →!shouldUseNarrowLayoutis false → the handler neither hides nor repositions the picker, leaving it stuck with stale positioning.Additionally, the
Popovercomponent switches between entirely different rendering paths at the breakpoint (PopoverWithoutOverlayportal on wide screens vsBOTTOM_DOCKEDModal on narrow screens), causing destructive unmount/remount transitions.Note: This is a pre-existing issue, not a regression from PR #87394 (which only wrapped the picker content in a React
<Activity>component).The fix should update the Dimensions change handler to use a ref for
shouldUseNarrowLayoutso the callback always reads the current value rather than a stale closure capture. Specifically:EmojiPicker.tsx, add a ref that tracksshouldUseNarrowLayout:Dimensions.addEventListener('change')callback (line 214), read fromshouldUseNarrowLayoutRef.currentinstead ofshouldUseNarrowLayout.isEmojiPickerVisiblein a ref and read from it in the callback, so the hide check uses current state.isEmojiPickerVisibleandshouldUseNarrowLayoutfrom the effect's dependency array (since they're now read from refs), which also prevents the listener from being torn down and recreated on every visibility/layout change.This ensures the handler always evaluates the current layout mode when a resize occurs, regardless of React's render timing.
Investigation details
Key files:
src/components/EmojiPicker/EmojiPicker.tsx:209-236— Dimension change handler with stale closuresrc/components/EmojiPicker/EmojiPicker.tsx:148-155—onModalHidenulls anchor refsrc/components/EmojiPicker/EmojiPickerButton.tsx:74— Cleanup effect nulls anchor ref on unmountsrc/components/Popover/index.tsx:78-124— Rendering path switch at breakpointsrc/components/PopoverWithMeasuredContent/PopoverWithMeasuredContentBase.tsx:74-86—shouldSkipRemeasurementprevents re-measuring after resizeData flow during bug:
PopoverWithoutOverlay.changefires with staleshouldUseNarrowLayout=false.EmojiPickerButtonto remount → cleanup nullsemojiPopoverAnchorRef.hideEmojiPicker().onModalHidecallback nulls anchor ref again.shouldUseNarrowLayout=true, but picker is already hidden.BOTTOM_DOCKEDModal (destructive transition).calculateAnchorPositionmay get{0,0,0,0}from the recently-nulled ref.Alternative explanations considered:
<Activity>wrapper — Ruled out. TheActivitycomponent only controls rendering priority; it doesn't affect the Dimensions listener or anchor ref lifecycle.shouldSkipRemeasurement=trueon the EmojiPicker'sPopoverWithMeasuredContent— This is a contributing factor (prevents re-measuring after hide/show cycle) but is secondary to the stale closure being the trigger.Next Steps for Contributor+ team: Reply with
@MelvinBot implement thisto create a draft PR,@MelvinBot <your feedback>to refine this analysis, or explain why you are rejecting Melvin's proposal.melvin-bot commentedon Apr 13, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @abdulrahuman5196 (
External)[-]Chat - Emoji picker is not displayed correctly in resized window[/-][+][$250] Chat - Emoji picker is not displayed correctly in resized window[/+]melvin-bot commentedon Apr 13, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022043831658429963643
trasnake87 commentedon Apr 13, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When the browser window is resized (for example, by toggling Chrome's device toolbar) while the emoji picker was previously opened, reopening the picker renders it at the wrong position — or not at all — until the window is resized again.
What is the root cause of that problem?
The root cause is in
PopoverWithMeasuredContentBase, which caches popover size/position state across open/close cycles. TheReact.memocomparator at https://github.com/Expensify/App/blob/main/src/components/PopoverWithMeasuredContent/PopoverWithMeasuredContentBase.tsx#L232-L237 short-circuits and returnstrue(no re-render) wheneverisVisibleisfalse, so while the picker is closed, any window resize is never propagated into this component —windowWidth/windowHeightandusePrevious(prevWindowDimensions)stay frozen at pre-resize values. When the picker is reopened, thehasWindowSizeChangedguard at https://github.com/Expensify/App/blob/main/src/components/PopoverWithMeasuredContent/PopoverWithMeasuredContentBase.tsx#L74-L86 compares the new anchor position against stale dimensions, so it takes the "no remeasurement needed" path and renders the Popover using stalepopoverWidth/popoverHeightand stale shift calculations.What changes do you think we should make in order to solve the problem?
Allow the memoized component to re-render when window dimensions change even while invisible, so
usePrevious(prevWindowDimensions)and the shift calculations stay fresh:Additionally, reset
isContentMeasuredwhenwindowWidth/windowHeightchange via auseEffect, so a reopen after resize forces a freshonLayoutmeasurement instead of reusing cachedpopoverHeight/popoverWidth.trasnake87 commentedon Apr 13, 2026
Contributor details
Your Expensify account email: trasnake87@gmail.com
Upwork Profile Link: https://www.upwork.com/freelancers/~010f770315ab181656
melvin-bot commentedon Apr 13, 2026
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
melvin-bot commentedon Apr 14, 2026
📣 @yw13931835525-cyber! 📣
Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:
Format:
twilight2294 commentedon Apr 14, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When the browser window is resized across the mobile/desktop breakpoint while the emoji picker is open (or was recently open), the picker renders at the wrong position or disappears entirely.
What is the root cause of that problem?
The
Dimensions.addEventListener('change')callback in EmojiPicker capturesshouldUseNarrowLayoutvia closure. When a resize crosses the 800px breakpoint, the event fires before React re-renders with the updated value. The callback reads the stale pre-resizeshouldUseNarrowLayout, so it either incorrectly hides the picker (desktop→mobile) or fails to reposition it (mobile→desktop), while the underlyingPopoverswitches between entirely different rendering paths (positioned popover vs.BOTTOM_DOCKEDmodal).What changes do you think we should make in order to solve the problem?
In EmojiPicker, use the event argument's
windowdimensions to compute the current layout instead of relying on the stale closure:This requires importing
variablesfrom@styles/variables.What alternative solutions did you explore? (Optional)
MelvinBot's proposal uses refs to track
shouldUseNarrowLayoutso the callback reads "current" values. This still has a race: the ref is updated during React's render phase, but theDimensionsevent fires before that render, so the ref can still hold the pre-resize value at callback time. Using the event's ownwindow.widthis race-free because the dimensions come directly from the event payload, not from React state or refs. It also explicitly detects breakpoint crossings (isNowNarrowLayout !== shouldUseNarrowLayout) and always closes the picker when the rendering mode switches, which neither existing proposal handles.trasnake87's proposal fixes
PopoverWithMeasuredContentBase's memo comparator to allow re-renders while invisible. This addresses a secondary symptom (stale cached measurements on reopen) but doesn't fix the primary cause: the dimension listener making wrong decisions with stale layout data during the resize itself.8 remaining items
melvin-bot commentedon Apr 17, 2026
@abdulrahuman5196 Whoops! This issue is 2 days overdue. Let's get this updated quick!
melvin-bot commentedon Apr 20, 2026
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸
melvin-bot commentedon Apr 21, 2026
@abdulrahuman5196 Still overdue 6 days?! Let's take care of this!
twilight2294 commentedon Apr 23, 2026
@abdulrahuman5196 can you please check my proposal here , thanks !
emkhalid commentedon Apr 23, 2026
Proposal
What is the root cause of that problem?
EmojiPickerandPopovercurrently read from two different sources of truth during a resize, and that is what produces the bug.src/components/Popover/index.tsxselects the picker's presentation mode from committed React state (shouldUseNarrowLayout/isSmallScreenWidth). On a wide screen it renders an anchoredPopoverWithoutOverlay; on a narrow screen it renders aBOTTOM_DOCKEDmodal that ignoresanchorPositionentirely.App/src/components/Popover/index.tsx
Lines 78 to 123 in 4c52779
src/components/EmojiPicker/EmojiPicker.tsx, however, decides whether to keep the picker open and where to anchor it from a rawDimensions.addEventListener('change')callback. Thechangeevent fires on the native resize tick, before React commits the re-render that flipsshouldUseNarrowLayoutand before the composer subtree finishes its remount. Inside that callback, three things can be transiently wrong at once:shouldUseNarrowLayoutis still the pre-resize value (closure capture)emojiPopoverAnchorRef.currentisnullbecauseEmojiPickerButton's cleanup ran during the layout shiftApp/src/components/EmojiPicker/EmojiPicker.tsx
Lines 209 to 236 in 4c52779
So on a desktop→mobile resize, the
isEmojiPickerVisible && !shouldUseNarrowLayoutbranch sees the stalefalse, finds a null anchor, and callshideEmojiPicker()— even thoughPopoveris about to switch to bottom-docked where no anchor is needed. On mobile→desktop, the staletrueskips the hide path but the anchor is still mid-remount, so the picker reopens with a stale anchor position. The fundamental mismatch is thatEmojiPicker's decision runs before the committed state thatPopoverreads, so the two components can never agree during the transition.What changes do you think we should make in order to solve the problem?
Make
EmojiPickerreact to the same committed responsive state thatPopoveralready reads, instead of subscribing to rawDimensionsevents.Concretely, drop the
Dimensions.addEventListener('change')subscription and replace it with auseEffectwhose dependency array contains the committedisSmallScreenWidth+windowWidth+windowHeight. React guarantees this effect runs after commit, so it fires exactly once the responsive tree (composer, anchor,Popover's presentation-mode switch) has settled. Then:Popoveris rendering the picker as bottom-docked and ignoresanchorPosition, so the picker stays open correctly through mobile resizing and soft-keyboard toggles without any imperative action.The diff against
src/components/EmojiPicker/EmojiPicker.tsx:App/src/components/EmojiPicker/EmojiPicker.tsx
Lines 209 to 236 in 4c52779
Why this fixes it:
isSmallScreenWidth, the composer's anchor ref, andPopover's presentation-mode switch are all in their post-resize states when we evaluate. There is no transient window left to act on.hideEmojiPicker()mis-trigger on desktop→mobile (bottom-docked mode needs no anchor) and also sidesteps soft-keyboard resize events on mobile that previously required a defensiveshouldUseNarrowLayoutcheck inside the listener.requestAnimationFramefires, the composer has laid out its remounted subtree, sogetEmojiPopoverAnchor()returns the new anchor. If it truly doesn't (e.g. the anchor was conditionally removed by a parent), hiding is the right call because an anchored popover cannot be rendered without one.windowWidth/windowHeightin the deps means the effect re-runs on every committed dimension change, so resizing within wide-mode (pane changes, window drags) still repositions cleanly.calculateAnchorPositionresolution, preventing out-of-order state writes during rapid resizing.What alternative solutions did you explore? (Optional)
Tracking
shouldUseNarrowLayoutandisEmojiPickerVisiblein refs inside the existingDimensionslistener (MelvinBot's proposal). The ref is assigned during render; theDimensionsevent fires on the native resize tick, which can precede React's render for that resize. So the ref still reads the pre-resize value at callback time. It narrows the race but does not close it, and it keepsEmojiPicker's logic out of sync withPopover's committed-state presentation choice.Reading
event.window.widthfrom theDimensionspayload to compute the breakpoint race-free (twilight2294's proposal). Race-free for reading width, but the callback still runs before commit. The anchor ref is still transiently null during the composer's remount, andPopoverhas not yet switched presentation modes. The listener decides against transient state in the middle of the transition; my effect decides against the committed state after the transition.Unblocking the
React.memocomparator onPopoverWithMeasuredContentBasewhile invisible, plus resettingisContentMeasuredon resize (trasnake87's proposal). This fixes a different, secondary issue (stale cached measurements on reopen). It does nothing about the primary cause:EmojiPicker's listener hiding or mispositioning the picker during the resize itself.Introducing a live
EmojiPopoverAnchorGetter, apopoverKeysession identity onPopoverProvider, and post-commit reconciliation (nabi-ebrahimi's proposal). Correct in spirit, but the scope is much larger than the bug requires: it changes the sharedshowEmojiPickerAPI, updates all four call sites (EmojiPickerButton,EmojiPickerButtonDropdown,AddReactionBubble,MiniQuickEmojiReactions), and adds logic toPopoverProvider. ThepopoverKey/ session-identity change targets a separate desktop-remount-close scenario that is not actually required to fix [$250] Chat - Emoji picker is not displayed correctly in resized window #87824's reported repro — the repro is "picker disappears / mispositions across a resize", and aligningEmojiPickerwithPopover's committed state is sufficient for that.Adding a global orientation/resize debounce outside
EmojiPicker. Rejected: it shifts the bug's timing without fixing the source-of-truth mismatch, and debounces hurt perceived responsiveness on other flows that share those dimensions.Demo
Screencast.From.2026-04-23.19-43-58.mp4
github-actions commentedon Apr 23, 2026
nabi-ebrahimi commentedon Apr 23, 2026
My proposal fix demo:
REC-20260423161942-compressed.mov
melvin-bot commentedon Apr 23, 2026
@abdulrahuman5196 8 days overdue is a lot. Should this be a Weekly issue? If so, feel free to change it!
twilight2294 commentedon Apr 24, 2026
@abdulrahuman5196 can you please review my proposal #87824 (comment)
abdulrahuman5196 commentedon Apr 26, 2026
I am sure if this is even an real issue. Seems like a very rare testing case in resize flow. I will ask about this in the slack channel - https://expensify.slack.com/archives/C02NK2DQWUX/p1777187683284119
melvin-bot commentedon Apr 27, 2026
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸
mallenexpensify commentedon Apr 27, 2026
Upon further review and discussing with @abdulrahuman5196 , we're going to close this due to not having a confirmed RCA and, with it being such a tiny bug, we don't want to mess things up elsewhere. Thanks for helping here.