Defer mounting Search filter dropdown content until opened#96287
Defer mounting Search filter dropdown content until opened#96287TMisiukiewicz wants to merge 3 commits into
Conversation
Codecov Report❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.
|
|
@carlosmiceli 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] |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c05319cb08
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@MelvinBot review |
There was a problem hiding this comment.
Pull request overview
This PR improves Search page performance by preventing heavy filter dropdown content from mounting until the user actually opens a filter dropdown, avoiding expensive option-building work during initial page focus/render (notably in large accounts).
Changes:
- Added a
hasEverExpandedlatch to defer popover content mounting until the dropdown is first opened. - Updated popover content creation to return
nulluntil the first open, while keeping content mounted afterward for fast reopen/close animations.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Review: LGTM ✅The approach is correct and low-risk. I verified the premise, the safety of the conditional, and the latching behavior. Why it works (premise confirmed): No Rules-of-Hooks risk (the thing I was most worried about): Latching is correct: Minor, non-blocking observations
Nice, tightly-scoped fix — the inline comment explaining why the deferral is needed is exactly the kind of context this warrants. |
|
Actually, we have a small visual glitch with this optimisation 2026-07-16.14.26.09.mov |
|
Although it is difficult to notice on video 😅 |
Reviewer Checklist
Screenshots/VideosAndroid: HybridApp2026-07-16.14.42.43.movAndroid: mWeb Chrome2026-07-16.14.40.21.moviOS: HybridApp2026-07-16.14.42.43.moviOS: mWeb Safari2026-07-16.14.40.21.movMacOS: Chrome / Safari2026-07-16.14.43.39.mov |
But okay |
|
Is it same on staging? I can notice it in your video |
|
PR doesn’t need product input as a refactor PR. Unassigning and unsubscribing myself. |
|
Yeah |
Explanation of Change
Opening a Search page (e.g. "Needs approval" with a
from:filter set) rendered every active filter chip's dropdown body eagerly, before the dropdown was ever opened. This happened becausePopoverWithMeasuredContentBasemounts its children even whileisVisible={false}, soFilterPopupButtonbuildingpopoverContentunconditionally on every render caused each filter selector (from/to/category/tag/…) to mount and run its option-list build on screen focus — including the expensiveusePersonalDetailSearchSelectorhook (~800ms on large accounts) used by the user selector.This change defers mounting the popover content until the dropdown is first opened, latched via a new
hasEverExpandedstate so it stays mounted afterward (close animation and reopening remain instant).popoverContentisnulluntil first open, so nothing heavy mounts on page load — the cost is paid once, on the user's first click, behind the existing loading placeholder.Performance impact: On large customer account, this saves ~800ms of computations on opening Needs approval page. Computation on filter opening happened before anyway and it lasts ~200ms - nothing changed here
Fixed Issues
$ #96288
PROPOSAL:
Tests
Offline tests
N/A
QA Steps
// TODO: These must be filled out, or the issue title must include "[No QA]."
Same as tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
ios.mov
iOS: mWeb Safari
MacOS: Chrome / Safari
web.mov