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
[Due for payment 2026-06-30] [$250] iOS mWeb - Date picker stays open after navigating forward/backward #91311
Version Number: TBD Reproducible in staging?: Yes Reproducible in production?: Yes If this was caught during regression testing, add the test name, ID and link from BrowserStack: N/A Email or phone of affected tester (no customers): N/A Issue reported by:@arosiclair Bug source: PR testing Device used: iOS Safari App Component: User Settings
Action Performed:
Go to staging.expensify.com
Go to Wallet
Click Add bank account
On the Bank Purpose Page choose Make Payments
Choose United States
Go through the flow until confirmation page
Click browser back button to go back to date of birth step
Click browser forward button a few times
Expected Result:
The date picker closes as the next step does not require it.
Actual Result:
The date picker is stuck on screen until clicked.
Same behavior for the date picker in company incorporation date.
changed the title [-][HOLD] iOS mWeb - Date picker stays open after navigating forward/backward[/-][+]iOS mWeb - Date picker stays open after navigating forward/backward[/+]on Jun 1, 2026
ℹ️ Confidence: Medium — strong code-level evidence for the mechanism below, but the iOS-Safari–specific timing has not been reproduced in a runtime trace. Treat the fix direction as a starting point.
What is the root cause of that problem?
The calendar opens through a deferred auto-focus that is decoupled from navigation, and the only auto-close path bails out when the calendar isn't visible yet. So a fast forward/back can leave the calendar opening after you've already navigated to the next sub-step, with nothing left to close it.
The bank-account sub-steps are React Navigation routes (the subPage param), so the browser back/forward buttons move between them (useSubPage/index.tsx:39-41). The Date-of-Birth sub-step renders the DatePicker with autoFocus (DateOfBirthStep.tsx:99-107), and focusing the field is what opens the calendar (onFocus={showDatePickerModal}, DatePicker/index.tsx:157).
That focus is deferred — it waits for the screen transition (transitionEnd, or a 1000 ms fallback) and then InteractionManager + isWindowReadyToFocus() before calling input.focus() (useAutoFocusInput.ts:69-126, CONST/index.ts:293).
The calendar's only browser-navigation close is the Popover popstate listener, which early-returns when the modal isn't visible (Popover/index.tsx:55-74):
constlistener=()=>{if(!isVisible){return;}// <-- bails if the calendar hasn't opened yet
...
onClose?.();};
So in the failing sequence: back → DOB (auto-focus scheduled, calendar not yet visible) → forward (popstate fires, but isVisible is still false, so nothing closes) → the deferred focus then opens the calendar, now stranded on a step that doesn't use it. iOS mWeb Safari is where this reproduces because its slower screen transitions widen the gap between navigation and the deferred open; on desktop the calendar is already visible when popstate fires, so it closes correctly.
Alternative explanations considered (and ruled out)
The internal-popstate guard wrongly suppressing the close — ruled out. The guard (isInternalPopstateInProgress) is only set by withInternalPopstate, which runs only when a modal opts into shouldHandleNavigationBack. DatePickerModal never passes that prop, so the guard is never armed for the calendar.
A deterministic logic bug in the popstate handler — ruled out by the platform signature. A pure logic bug would also reproduce on desktop Chrome; this is iOS mWeb Safari only, which points to a timing race, not a static logic error.
"Auto-focus reopens on every visit to DOB" — that's expected behavior on the DOB step; the report is specifically that the calendar persists on a step that does not use it, which only the deferred-open race explains.
What changes do you think we should make in order to solve the problem?
Make the calendar's open state follow the navigation, so it can't open (or linger) after the user leaves the step. Two complementary guards in DatePicker/index.tsx:
Cancel/suppress the pending open and close the calendar when the field's screen blurs or the DatePicker unmounts. A useFocusEffect cleanup (and/or an unmount effect) that calls cancelAutoFocus() and setIsModalVisible(false) prevents the deferred input.focus() from opening a calendar after navigation has moved on.
Don't open if the screen is no longer focused. Guard showDatePickerModal so a late-firing focus is a no-op when the screen/sub-step is no longer the active one.
This keeps the fix scoped to the DatePicker rather than weakening the shared Popover popstate logic. Verification should be a manual iOS mWeb Safari repro of the exact back→forward sequence, since the race is platform-timing-dependent.
What alternative solutions did you explore? (Optional)
Closing the calendar from the Popover side regardless of isVisible (e.g., always running onClose on popstate) — rejected as too broad: it changes shared behavior for every Popover consumer and still wouldn't stop the deferred auto-focus from re-opening the calendar a moment later.
Next Steps for Contributor+ team: To accept:@MelvinBot implement [this](https://github.com/Expensify/App/issues/91311) to create a draft PR. To refine:@MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.
🚨 Edited by proposal-police: This proposal was edited at 2026-06-01 16:35:45 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
On iOS mWeb Safari, the date picker calendar in the Add bank account flow (the date of birth step and the company incorporation date step) stays open on screen after the user navigates with the browser back and then forward buttons. The calendar should dismiss when navigation lands on a step that no longer needs it, but instead it remains stuck on screen until the user taps it.
What is the root cause of that problem?
The date picker calendar opens through DatePickerModal, which renders a PopoverWithMeasuredContent:
PopoverWithMeasuredContent is responsive: on small screen widths (which includes iOS mWeb Safari) it does not render a Popover at all — it returns a bottom-docked Modal early:
This matters because the two render targets close on browser navigation through different mechanisms. The Popover (wide-screen) path closes via its own popstate listener, which is gated on shouldCloseWhenBrowserNavigationChanged. The Modal (small-screen) path is different: it only attaches a popstate listener when shouldHandleNavigationBack is set, and it ignores shouldCloseWhenBrowserNavigationChanged entirely:
DatePickerModal forwards shouldCloseWhenBrowserNavigationChanged but never sets shouldHandleNavigationBack. So on iOS mWeb the calendar is a Modal with no popstate listener attached: pressing the browser back/forward buttons fires no handler, onClose is never called, and the calendar stays stuck on screen. The same DatePicker/DatePickerModal path backs both the date of birth field and the company incorporation date field, which is why both reproduce.
Note that the calendar's own sub-pickers already do the right thing: MonthPickerModal and YearPickerModal render their Modal with shouldHandleNavigationBack, so they dismiss correctly on browser navigation:
Only the top-level date picker calendar omits it. (A recent change wired the wide-screen Popover path by passing shouldCloseWhenBrowserNavigationChanged from DatePicker, but that prop has no effect on the small-screen Modal path, so the iOS mWeb case remained broken.)
What changes do you think we should make in order to solve the problem?
Make the small-screen Modal honor browser back/forward the same way the wide-screen Popover already does. In DatePickerModal, pass shouldHandleNavigationBack to PopoverWithMeasuredContent, scoped to small screens and derived from the existing browser-navigation-close intent:
isSmallScreenWidth is already available in DatePickerModal. With this in place, on iOS mWeb the bottom-docked Modal registers its popstate listener (per Modal's showModal), so pressing browser back/forward fires the handler and calls onClose, which sets the picker invisible and dismisses the calendar. This mirrors what MonthPickerModal/YearPickerModal already do with shouldHandleNavigationBack, and it fixes both the date of birth and company incorporation date pickers because they share this path.
Scoping the prop to isSmallScreenWidth deliberately leaves the wide-screen Popover path untouched, since that path is already handled by shouldCloseWhenBrowserNavigationChanged and we don't want to alter its existing close behavior.
What alternative solutions did you explore? (Optional)
An alternative is to map shouldCloseWhenBrowserNavigationChanged to shouldHandleNavigationBack inside PopoverWithMeasuredContent's small-screen branch, so every consumer that opts into browser-navigation close gets it on the Modal path too. This is more general but changes shared behavior for other PopoverWithMeasuredContent consumers (for example the Search filter dropdown), so the targeted change in DatePickerModal is safer and scoped to the reported component.
Another alternative is to add explicit cleanup in DatePicker (for example a useFocusEffect that closes the calendar when the screen loses focus). This is heavier than needed: the Modal infrastructure already has a dedicated browser-navigation close path via shouldHandleNavigationBack; the date picker simply was not opting into it on small screens.
The affected bank-account date fields use the shared DatePicker input. Both DOB and company incorporation date render InputWrapper with InputComponent={DatePicker} and autoFocus:
When the field is focused, DatePicker opens DatePickerModal. The standard DatePicker path opts into browser-navigation dismissal by passing shouldCloseWhenBrowserNavigationChanged to DatePickerModal, and DatePickerModal forwards that intent to PopoverWithMeasuredContent:
The app already has close-on-browser-navigation behavior in the normal Popover path: Popover listens for popstate and calls onClose when shouldCloseWhenBrowserNavigationChanged is enabled:
But iOS Safari mWeb uses the small-screen PopoverWithMeasuredContent path. On small screens, PopoverWithMeasuredContent bypasses Popover and renders Modal directly as a bottom-docked modal:
That direct Modal path does not consume shouldCloseWhenBrowserNavigationChanged. So browser Back/Forward changes the bank-account substep route, but the date picker modal remains visible over the next step because the close intent never reaches a popstate listener in the reproducing layout.
What changes do you think we should make in order to solve the problem?
Use the existing browser-navigation-close behavior for the shared date input, and make sure it works in the small-screen web path.
Keep the standard DatePicker path opted into shouldCloseWhenBrowserNavigationChanged, and let DOB/incorporation-date inherit the behavior through the shared date picker rather than adding screen-specific cleanup.
In PopoverWithMeasuredContent, make the small-screen direct-Modal branch honor shouldCloseWhenBrowserNavigationChanged by adding a popstate listener that calls onClose when the popover is visible.
Make that listener web-only (Platform.OS === 'web' and browser event API available), because PopoverWithMeasuredContent is shared with Android/iOS native and browser popstate APIs do not exist there.
Preserve explicit false overrides. Consumers such as search/filter dropdowns that pass shouldCloseWhenBrowserNavigationChanged={false} should not attach this listener and should keep their current nested-selection behavior.
Ignore internal modal cleanup popstates with isInternalPopstateInProgress(), matching the existing Popover behavior.
This does not use shouldHandleNavigationBack, does not push a modal guard history entry, and does not call history.back(). Browser Forward continues normally; the picker closes as a side effect of the real browser navigation.
What alternative solutions did you explore? (Optional)
I considered only passing shouldCloseWhenBrowserNavigationChanged={true} from DatePicker, but that is incomplete for this bug because the iOS mWeb path uses the small-screen PopoverWithMeasuredContent branch that never reaches Popover's listener.
I considered using shouldHandleNavigationBack, but that would push a modal guard history entry and make browser Back close the picker instead of simply allowing navigation to proceed. The expected behavior here is to allow the browser navigation and close the picker as a consequence of that navigation.
I also considered moving the listener into DatePickerModal only. That would be narrower, but PopoverWithMeasuredContent already receives the shouldCloseWhenBrowserNavigationChanged prop and the bug is that its small-screen web branch ignores it. Handling the prop in PopoverWithMeasuredContent keeps behavior consistent with the existing Popover path while still preserving explicit opt-outs and native safety through the web-only guard.
changed the title [-]iOS mWeb - Date picker stays open after navigating forward/backward[/-][+][$250] iOS mWeb - Date picker stays open after navigating forward/backward[/+]on Jun 1, 2026
@marufsharifi@x-dev90 can you please accept the job below? Please reply here and tag me once you have.
If you're not sent an offer in Upwork when you're assigned to an issue, please tag me. If an Upwork job exists, please submit a proposal. https://www.upwork.com/jobs/~022061472075348511604
Activity
[-][HOLD] iOS mWeb - Date picker stays open after navigating forward/backward[/-][+]iOS mWeb - Date picker stays open after navigating forward/backward[/+]MelvinBot commentedon Jun 1, 2026
Proposal
What is the root cause of that problem?
The calendar opens through a deferred auto-focus that is decoupled from navigation, and the only auto-close path bails out when the calendar isn't visible yet. So a fast forward/back can leave the calendar opening after you've already navigated to the next sub-step, with nothing left to close it.
The bank-account sub-steps are React Navigation routes (the
subPageparam), so the browser back/forward buttons move between them (useSubPage/index.tsx:39-41). The Date-of-Birth sub-step renders theDatePickerwithautoFocus(DateOfBirthStep.tsx:99-107), and focusing the field is what opens the calendar (onFocus={showDatePickerModal},DatePicker/index.tsx:157).That focus is deferred — it waits for the screen transition (
transitionEnd, or a 1000 ms fallback) and thenInteractionManager+isWindowReadyToFocus()before callinginput.focus()(useAutoFocusInput.ts:69-126,CONST/index.ts:293).The calendar's only browser-navigation close is the Popover
popstatelistener, which early-returns when the modal isn't visible (Popover/index.tsx:55-74):So in the failing sequence: back → DOB (auto-focus scheduled, calendar not yet visible) → forward (popstate fires, but
isVisibleis stillfalse, so nothing closes) → the deferred focus then opens the calendar, now stranded on a step that doesn't use it. iOS mWeb Safari is where this reproduces because its slower screen transitions widen the gap between navigation and the deferred open; on desktop the calendar is already visible whenpopstatefires, so it closes correctly.Alternative explanations considered (and ruled out)
isInternalPopstateInProgress) is only set bywithInternalPopstate, which runs only when a modal opts intoshouldHandleNavigationBack.DatePickerModalnever passes that prop, so the guard is never armed for the calendar.What changes do you think we should make in order to solve the problem?
Make the calendar's open state follow the navigation, so it can't open (or linger) after the user leaves the step. Two complementary guards in
DatePicker/index.tsx:DatePickerunmounts. AuseFocusEffectcleanup (and/or an unmount effect) that callscancelAutoFocus()andsetIsModalVisible(false)prevents the deferredinput.focus()from opening a calendar after navigation has moved on.showDatePickerModalso a late-firing focus is a no-op when the screen/sub-step is no longer the active one.This keeps the fix scoped to the DatePicker rather than weakening the shared Popover
popstatelogic. Verification should be a manual iOS mWeb Safari repro of the exact back→forward sequence, since the race is platform-timing-dependent.What alternative solutions did you explore? (Optional)
Closing the calendar from the Popover side regardless of
isVisible(e.g., always runningonCloseonpopstate) — rejected as too broad: it changes shared behavior for every Popover consumer and still wouldn't stop the deferred auto-focus from re-opening the calendar a moment later.Next Steps for Contributor+ team:
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/issues/91311)to create a draft PR.To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting Melvin's proposal.
wildan-m commentedon Jun 1, 2026
🚨 Edited by proposal-police: This proposal was edited at 2026-06-01 16:35:45 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
On iOS mWeb Safari, the date picker calendar in the Add bank account flow (the date of birth step and the company incorporation date step) stays open on screen after the user navigates with the browser back and then forward buttons. The calendar should dismiss when navigation lands on a step that no longer needs it, but instead it remains stuck on screen until the user taps it.
What is the root cause of that problem?
The date picker calendar opens through
DatePickerModal, which renders aPopoverWithMeasuredContent:App/src/components/DatePicker/DatePickerModal.tsx
Lines 66 to 73 in 5246665
PopoverWithMeasuredContentis responsive: on small screen widths (which includes iOS mWeb Safari) it does not render aPopoverat all — it returns a bottom-dockedModalearly:App/src/components/PopoverWithMeasuredContent/index.tsx
Lines 31 to 41 in 5246665
This matters because the two render targets close on browser navigation through different mechanisms. The
Popover(wide-screen) path closes via its ownpopstatelistener, which is gated onshouldCloseWhenBrowserNavigationChanged. TheModal(small-screen) path is different: it only attaches apopstatelistener whenshouldHandleNavigationBackis set, and it ignoresshouldCloseWhenBrowserNavigationChangedentirely:App/src/components/Modal/index.tsx
Lines 82 to 92 in 5246665
DatePickerModalforwardsshouldCloseWhenBrowserNavigationChangedbut never setsshouldHandleNavigationBack. So on iOS mWeb the calendar is aModalwith nopopstatelistener attached: pressing the browser back/forward buttons fires no handler,onCloseis never called, and the calendar stays stuck on screen. The sameDatePicker/DatePickerModalpath backs both the date of birth field and the company incorporation date field, which is why both reproduce.Note that the calendar's own sub-pickers already do the right thing:
MonthPickerModalandYearPickerModalrender theirModalwithshouldHandleNavigationBack, so they dismiss correctly on browser navigation:App/src/components/DatePicker/CalendarPicker/MonthPickerModal.tsx
Lines 63 to 73 in 5246665
Only the top-level date picker calendar omits it. (A recent change wired the wide-screen
Popoverpath by passingshouldCloseWhenBrowserNavigationChangedfromDatePicker, but that prop has no effect on the small-screenModalpath, so the iOS mWeb case remained broken.)What changes do you think we should make in order to solve the problem?
Make the small-screen
Modalhonor browser back/forward the same way the wide-screenPopoveralready does. InDatePickerModal, passshouldHandleNavigationBacktoPopoverWithMeasuredContent, scoped to small screens and derived from the existing browser-navigation-close intent:shouldHandleNavigationBack={isSmallScreenWidth && shouldCloseWhenBrowserNavigationChanged}isSmallScreenWidthis already available inDatePickerModal. With this in place, on iOS mWeb the bottom-dockedModalregisters itspopstatelistener (perModal'sshowModal), so pressing browser back/forward fires the handler and callsonClose, which sets the picker invisible and dismisses the calendar. This mirrors whatMonthPickerModal/YearPickerModalalready do withshouldHandleNavigationBack, and it fixes both the date of birth and company incorporation date pickers because they share this path.Scoping the prop to
isSmallScreenWidthdeliberately leaves the wide-screenPopoverpath untouched, since that path is already handled byshouldCloseWhenBrowserNavigationChangedand we don't want to alter its existing close behavior.Compare branch: https://github.com/Expensify/App/compare/main...wildan-m:App:wildan/91311-date-picker-mweb-nav-close?expand=1
What alternative solutions did you explore? (Optional)
An alternative is to map
shouldCloseWhenBrowserNavigationChangedtoshouldHandleNavigationBackinsidePopoverWithMeasuredContent's small-screen branch, so every consumer that opts into browser-navigation close gets it on theModalpath too. This is more general but changes shared behavior for otherPopoverWithMeasuredContentconsumers (for example the Search filter dropdown), so the targeted change inDatePickerModalis safer and scoped to the reported component.Another alternative is to add explicit cleanup in
DatePicker(for example auseFocusEffectthat closes the calendar when the screen loses focus). This is heavier than needed: theModalinfrastructure already has a dedicated browser-navigation close path viashouldHandleNavigationBack; the date picker simply was not opting into it on small screens.melvin-bot commentedon Jun 1, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @marufsharifi (
External)KJ21-ENG commentedon Jun 1, 2026
Proposal
What is the root cause of that problem?
The affected bank-account date fields use the shared
DatePickerinput. Both DOB and company incorporation date renderInputWrapperwithInputComponent={DatePicker}andautoFocus:App/src/components/SubStepForms/DateOfBirthStep.tsx
Lines 98 to 110 in eaaffe3
App/src/pages/ReimbursementAccount/USD/BusinessInfo/subSteps/IncorporationDateBusiness.tsx
Lines 72 to 81 in eaaffe3
When the field is focused,
DatePickeropensDatePickerModal. The standardDatePickerpath opts into browser-navigation dismissal by passingshouldCloseWhenBrowserNavigationChangedtoDatePickerModal, andDatePickerModalforwards that intent toPopoverWithMeasuredContent:App/src/components/DatePicker/index.tsx
Lines 205 to 217 in 2fa5241
App/src/components/DatePicker/DatePickerModal.tsx
Lines 67 to 83 in 2fa5241
The app already has close-on-browser-navigation behavior in the normal
Popoverpath:Popoverlistens forpopstateand callsonClosewhenshouldCloseWhenBrowserNavigationChangedis enabled:App/src/components/Popover/index.tsx
Lines 52 to 74 in 2fa5241
But iOS Safari mWeb uses the small-screen
PopoverWithMeasuredContentpath. On small screens,PopoverWithMeasuredContentbypassesPopoverand rendersModaldirectly as a bottom-docked modal:App/src/components/PopoverWithMeasuredContent/index.tsx
Lines 31 to 40 in 2fa5241
That direct
Modalpath does not consumeshouldCloseWhenBrowserNavigationChanged. So browser Back/Forward changes the bank-account substep route, but the date picker modal remains visible over the next step because the close intent never reaches apopstatelistener in the reproducing layout.What changes do you think we should make in order to solve the problem?
Use the existing browser-navigation-close behavior for the shared date input, and make sure it works in the small-screen web path.
DatePickerpath opted intoshouldCloseWhenBrowserNavigationChanged, and let DOB/incorporation-date inherit the behavior through the shared date picker rather than adding screen-specific cleanup.PopoverWithMeasuredContent, make the small-screen direct-Modalbranch honorshouldCloseWhenBrowserNavigationChangedby adding apopstatelistener that callsonClosewhen the popover is visible.Platform.OS === 'web'and browser event API available), becausePopoverWithMeasuredContentis shared with Android/iOS native and browserpopstateAPIs do not exist there.falseoverrides. Consumers such as search/filter dropdowns that passshouldCloseWhenBrowserNavigationChanged={false}should not attach this listener and should keep their current nested-selection behavior.isInternalPopstateInProgress(), matching the existingPopoverbehavior.This does not use
shouldHandleNavigationBack, does not push a modal guard history entry, and does not callhistory.back(). Browser Forward continues normally; the picker closes as a side effect of the real browser navigation.What alternative solutions did you explore? (Optional)
I considered only passing
shouldCloseWhenBrowserNavigationChanged={true}fromDatePicker, but that is incomplete for this bug because the iOS mWeb path uses the small-screenPopoverWithMeasuredContentbranch that never reachesPopover's listener.I considered using
shouldHandleNavigationBack, but that would push a modal guard history entry and make browser Back close the picker instead of simply allowing navigation to proceed. The expected behavior here is to allow the browser navigation and close the picker as a consequence of that navigation.I also considered moving the listener into
DatePickerModalonly. That would be narrower, butPopoverWithMeasuredContentalready receives theshouldCloseWhenBrowserNavigationChangedprop and the bug is that its small-screen web branch ignores it. Handling the prop inPopoverWithMeasuredContentkeeps behavior consistent with the existingPopoverpath while still preserving explicit opt-outs and native safety through the web-only guard.Comparison branch :- https://github.com/Expensify/App/compare/main...KJ21-ENG:App:KJ21-ENG/91311-datepicker-browser-nav-compare?expand=1
Reproducing issue + proof of working fix :-
Screen.Recording.2026-06-02.at.2.03.01.AM.mov
Screen.Recording.2026-06-02.at.2.06.02.AM.mov
[-]iOS mWeb - Date picker stays open after navigating forward/backward[/-][+][$250] iOS mWeb - Date picker stays open after navigating forward/backward[/+]60 remaining items
melvin-bot commentedon Jun 29, 2026
Triggered auto assignment to @mallenexpensify (
Awaiting Payment)melvin-bot commentedon Jun 29, 2026
Payment Summary
Upwork Job
BugZero Checklist (@mallenexpensify)
mallenexpensify commentedon Jul 2, 2026
@marufsharifi @x-dev90 can you please accept the job below? Please reply here and tag me once you have.
If you're not sent an offer in Upwork when you're assigned to an issue, please tag me. If an Upwork job exists, please submit a proposal.
https://www.upwork.com/jobs/~022061472075348511604
^ Test case created. Thx
marufsharifi commentedon Jul 4, 2026
@mallenexpensify, I've accepted the offer. thanks.
x-dev90 commentedon Jul 6, 2026
@mallenexpensify, The offer accepted, could you please process the payment. thanks.
mallenexpensify commentedon Jul 6, 2026
Payment Summary
Contributor: @x-dev90 paid $250 via Upwork
Contributor+: @marufsharifi paid $250 via Upwork
Thx!