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
Spend - Filter popover closes after selecting month in RHP #91670
Version Number: 9.3.82-0 Reproducible in staging?: Yes Reproducible in production?: No If this was caught during regression testing, add the test name, ID and link from BrowserStack:#90029 Email or phone of affected tester (no customers):sdjsodnjiodsjsoinj1@gmail.com Issue reported by: Applause Internal Team Bug source: Exploratory - Significant User Experience Deterioration Device used: Mac 26.5 / Chrome App Component: Search
Action Performed:
Go to staging.new.expensify.com
Go to Spend > Expenses.
Click Filters.
Hover over Date.
Click Custom date.
Click on the month.
Select another month.
Expected Result:
Filter popover will not close after selecting month in RHP.
Actual Result:
Filter popover closes after selecting month in RHP.
👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:
Identify the pull request that introduced this issue and revert it.
Both the filter popover and the MonthPickerModal use shouldHandleNavigationBack, which makes each Modal push a browser history entry and register a popstate listener that calls onClose (Modal/index.tsx:65-73).
When a month is selected, the MonthPickerModal closes → its Modal calls window.history.back() (Modal/index.tsx:54-58) → the resulting popstate event is caught by the filter popover's Modal-level listener (Modal/index.tsx:42-44) → the filter popover closes.
The existing shouldCloseWhenBrowserNavigationChanged={false} on FilterPopupButton.tsx:138 only guards the Popover-level popstate listener in Popover/index.tsx, not the Modal-level one. So the filter popover is still vulnerable to popstate events from nested modals closing. The same issue affects YearPickerModal.
What changes do you think we should make in order to solve the problem?
The Modal's handlePopState listener should verify that the popstate event is actually meant for it before calling onClose. One approach: when showModal pushes the history entry, tag it with a unique identifier (e.g., a random ID stored in window.history.state). When handlePopState fires, check whether the current window.history.state still has the expected tag — if it doesn't match, the popstate was consumed by a different modal's history.back() and should be ignored.
Alternatively, the simpler fix: when shouldCloseWhenBrowserNavigationChanged is false, skip registering the Modal-level popstate listener in showModal as well (currently only the Popover-level listener respects this prop). This would require threading the prop through from PopoverWithMeasuredContent → Popover → Modal.
What alternative solutions did you explore? (Optional)
Removing shouldHandleNavigationBack from MonthPickerModal/YearPickerModal — this would break standalone back-navigation for those modals when opened outside a popover context.
Removing shouldHandleNavigationBack from FilterPopupButton — this would break back-button behavior for the filter popover itself.
Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.
godzillaxbox19982014-lgtm commented on May 26, 2026
One implementation detail from checking the video/code: the month row click only changes local CalendarPicker.currentDateView; it should not write any dateOn/dateAfter/dateBefore/dateRange value or search query until a day/apply happens. So a low-risk patch can be scoped to the desktop filter popover history handling: keep shouldHandleNavigationBack for the small-screen/fullscreen filter modal path, but do not install that parent popstate listener for the desktop popover that hosts the Month/Year RHPs. I would also make the popover onClose an explicit close instead of toggleOverlay, so any late child-modal close event cannot flip it open/closed unexpectedly.
Verified against the attached clip: after selecting a month, the child RHP closes and the whole filter UI drops back to the table, before any date value is applied.
Still not sure how to handle this. Both modals set shouldHandleNavigationBack to true, which adds a popstate listener that will close the modal. When popstate is triggered, all modals that have shouldHandleNavigationBack set will be closed as well.
Activity
applause-bot commentedon May 26, 2026
While Applause doesn't embed attachments for this bug, here are the links for quick view:
https://platform.applause.com/services/links/v1/external/1851d60168754ac6df12513f0be14fa762dc937aceff366786723688f597ba1c
melvin-bot commentedon May 26, 2026
You have been assigned to this deploy blocker because you recently merged this PR: #90029
melvin-bot commentedon May 26, 2026
💬 A slack conversation has been started in #expensify-open-source
github-actions commentedon May 26, 2026
👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:
MelvinBot commentedon May 26, 2026
Proposal
What is the root cause of that problem?
Both the filter popover and the MonthPickerModal use
shouldHandleNavigationBack, which makes each Modal push a browser history entry and register apopstatelistener that callsonClose(Modal/index.tsx:65-73).When a month is selected, the MonthPickerModal closes → its Modal calls
window.history.back()(Modal/index.tsx:54-58) → the resultingpopstateevent is caught by the filter popover's Modal-level listener (Modal/index.tsx:42-44) → the filter popover closes.The existing
shouldCloseWhenBrowserNavigationChanged={false}onFilterPopupButton.tsx:138only guards the Popover-levelpopstatelistener inPopover/index.tsx, not the Modal-level one. So the filter popover is still vulnerable topopstateevents from nested modals closing. The same issue affects YearPickerModal.What changes do you think we should make in order to solve the problem?
The Modal's
handlePopStatelistener should verify that thepopstateevent is actually meant for it before callingonClose. One approach: whenshowModalpushes the history entry, tag it with a unique identifier (e.g., a random ID stored inwindow.history.state). WhenhandlePopStatefires, check whether the currentwindow.history.statestill has the expected tag — if it doesn't match, the popstate was consumed by a different modal'shistory.back()and should be ignored.Alternatively, the simpler fix: when
shouldCloseWhenBrowserNavigationChangedisfalse, skip registering the Modal-levelpopstatelistener inshowModalas well (currently only the Popover-level listener respects this prop). This would require threading the prop through fromPopoverWithMeasuredContent→Popover→Modal.What alternative solutions did you explore? (Optional)
shouldHandleNavigationBackfrom MonthPickerModal/YearPickerModal — this would break standalone back-navigation for those modals when opened outside a popover context.shouldHandleNavigationBackfrom FilterPopupButton — this would break back-button behavior for the filter popover itself.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.godzillaxbox19982014-lgtm commentedon May 26, 2026
One implementation detail from checking the video/code: the month row click only changes local
CalendarPicker.currentDateView; it should not write anydateOn/dateAfter/dateBefore/dateRangevalue or search query until a day/apply happens. So a low-risk patch can be scoped to the desktop filter popover history handling: keepshouldHandleNavigationBackfor the small-screen/fullscreen filter modal path, but do not install that parent popstate listener for the desktop popover that hosts the Month/Year RHPs. I would also make the popoveronClosean explicit close instead oftoggleOverlay, so any late child-modal close event cannot flip it open/closed unexpectedly.Verified against the attached clip: after selecting a month, the child RHP closes and the whole filter UI drops back to the table, before any date value is applied.
bernhardoj commentedon May 26, 2026
Still not sure how to handle this. Both modals set
shouldHandleNavigationBackto true, which adds a popstate listener that will close the modal. When popstate is triggered, all modals that haveshouldHandleNavigationBackset will be closed as well.bernhardoj commentedon May 26, 2026
^ This is a modal bug, so I think we can demote this
JS00001 commentedon May 26, 2026
We should not demote this, this makes the feature not work well
JS00001 commentedon May 26, 2026
Fixed by CP, popup no longer exists
JS00001 commentedon May 26, 2026
@bernhardoj we had a similar issue for the 'date' filter popup/chip. We can use that logic here I think
bernhardoj commentedon May 27, 2026
@JS00001 this issue happens on the 'date' filter chip too. This happens after we add
shouldHandleNavigationBackto the filter popup.bernhardoj commentedon May 27, 2026
I decided to remove
shouldHandleNavigationBackfrom the filters popup and return null when the screen isn't focused