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
[$250] mWeb - Avatar - Discard changes modal cannot be closed after swiping back and tapping Cancel #92793
iOS mWeb Safari swipe-back: the browser-native swipe completes before RN can intercept it, so RN only catches up via popstate → the transitionStart listener (index.ts:121-136). This is the path that shows the modal on swipe-back.
When the user taps Cancel, the global Modal's hideModal runs a deferred window.history.back() (Modal/index.tsx:63-80) to consume the synthetic {shouldGoBack: true} history entry it pushed when it opened. That history.back() fires popstate, which makes RN fire transitionStart again.
The transitionStart listener has no re-entry guard — it only checks getHasUnsavedChanges() (still true, because Cancel correctly keeps the form dirty). So it immediately re-runs window.history.go(1) + showDiscardModal() and the modal pops straight back up. The modal can never be dismissed. This is iOS mWeb Safari only because that is the only platform where the modal is opened via transitionStart instead of beforeRemove.
The recent fix for the sibling issue #86585 (PR #89789) added the shouldIgnoreNextBeforeRemove / markNextBeforeRemoveAsModalCleanup guard — but that guard is only consulted in the beforeRemove path (index.ts:100-104), never in transitionStart. That is why it fixed the header-back-button case but left the iOS swipe-back case broken.
Step-by-step event timeline (swipe-back → Cancel)
Form is dirty (custom avatar selected). User swipes back in Safari → browser back completes → popstate.
RN fires transitionStart (closing: true). Listener sets shouldNavigateBack.current = true, calls window.history.go(1) to undo the back.
history.go(1) re-fires transitionStart (closing: false) → listener calls navigateAfterInteraction(showDiscardModal) → modal opens; Modal.showModal pushes a {shouldGoBack: true} history entry (Modal/index.tsx:82-92).
The deferred history.back() fires popstate → RN fires transitionStartagain → listener has no guard → re-shows the modal. Loop.
What changes do you think we should make in order to solve the problem?
Make the transitionStart listener ignore the navigation event that originates from the Modal's own internal history.back(), exactly the way Popover/index.tsx already does for this same class of re-entrancy.
There is a purpose-built helper for this: isInternalPopstateInProgress() — it returns true precisely while the Modal's withInternalPopstate(() => history.back()) is running. At the top of the transitionStart listener in useDiscardChangesConfirmation/index.ts:121-136, return early (without history.go(1) or showDiscardModal()) when the popstate is internal. This stops the Cancel-triggered history.back() from re-opening the modal, while still reacting to genuine user swipe-backs.
What alternative solutions did you explore? (Optional)
Mirror the beforeRemove guard: add if (isDiscardModalOpen.current || shouldIgnoreNextBeforeRemove.current) { return; } at the top of the transitionStart listener — reusing the shouldIgnoreNextBeforeRemove flag that markNextBeforeRemoveAsModalCleanup already arms for ~250ms on Cancel. This works because the flag is armed before the deferred history.back() fires, but it is timing-dependent (250ms window); the isInternalPopstateInProgress() approach is deterministic and preferred.
Next Steps for Contributor+ team: To accept:@MelvinBot implement [this](https://github.com/Expensify/App/issues/92793) 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-05 18:03:04 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
On mWeb Safari, after selecting an avatar on the Edit profile picture page, swiping back to trigger the Discard changes confirmation, and tapping Cancel, the modal briefly animates out and then immediately re-appears. It can never be dismissed via Cancel because each Cancel tap is followed by an instant re-open, leaving the user permanently stuck on the discard prompt.
What is the root cause of that problem?
The Discard changes flow on web is driven by useDiscardChangesConfirmation, which listens to React Navigation's transitionStart event to detect browser-level back navigation (e.g. an iOS Safari swipe back) and reopen the page with window.history.go(1) while showing the confirm modal. The confirm modal itself is rendered through useConfirmModal -> ConfirmModalWrapper with shouldHandleNavigationBack: true, which makes Modal/index.tsx push an extra browser history entry tagged shouldGoBack: true when the modal opens and pop it back with withInternalPopstate(() => window.history.back()) when it closes:
A recent fix (markNextBeforeRemoveAsModalCleanup) was added precisely to prevent that cleanup history.back() from re-firing the discard modal, by setting shouldIgnoreNextBeforeRemove.current = true for 250ms when the modal closes. The flag is consumed in the useBeforeRemove handler, which guards the in-app navigation path. But on mWeb Safari, the swipe back never goes through beforeRemove (the comment in the hook explicitly states: "We cannot programmatically stop the browser's back navigation like react-navigation's beforeRemove"). It goes through transitionStart instead — and the transitionStart listener has no equivalent guard:
So the sequence on Cancel is: (1) ConfirmModalWrapper.handleCancel flips isVisible to false, the modal animates out, and Modal/index.tsx.hideModal schedules withInternalPopstate(() => window.history.back()) in a setTimeout(0). (2) The hook's .then() runs, calling markNextBeforeRemoveAsModalCleanup() (sets shouldIgnoreNextBeforeRemove = true), resetting isDiscardModalOpen.current = false, and clearing shouldNavigateBack.current = false. (3) The deferred history.back() fires popstate; React Navigation's useLinking resets the root to the AvatarPage record, which emits a fresh transitionStart while getHasUnsavedChanges() is still true (the avatar selection lives on selected/imageData state and was never cleared by Cancel). (4) The transitionStart listener doesn't check shouldIgnoreNextBeforeRemove.current or isDiscardModalOpen.current, so it runs window.history.go(1) and immediately calls navigateAfterInteraction(showDiscardModal) again — pushing a brand-new ConfirmModalWrapper onto the global modal stack:
shouldNavigateBack.current=true;if(closing){window.history.go(1);return;}window.history.go(1);navigateAfterInteraction(showDiscardModal);// <- fires again after Cancel cleanup
Visually this looks like Cancel "did nothing": the user's tap closes modal A, but modal B is pushed onto the stack in the same frame, and ModalContext only renders the topmost modal (modalStack.modals.at(-1)), so the prompt never disappears. Every subsequent Cancel just trades modal N for modal N+1.
What changes do you think we should make in order to solve the problem?
Extend the existing modal-cleanup suppression so it also short-circuits the transitionStart re-trigger, mirroring what useBeforeRemove already does. The hook already owns shouldIgnoreNextBeforeRemove and the 250ms self-clearing timer set by markNextBeforeRemoveAsModalCleanup — we just need to honor it on the web back path too, and clear it on consumption so it doesn't leak into a real subsequent back gesture. We should also guard against isDiscardModalOpen.current to avoid the edge case where the initial swipe-back popstate chain queues two showDiscardModal calls before the first one mounts.
Concretely, in src/hooks/useDiscardChangesConfirmation/index.ts, update the transitionStart listener to consume the cleanup flag and bail out, and avoid stacking a second modal:
navigation.addListener('transitionStart',({data: {closing}})=>{if(!getHasUnsavedChanges()){return;}if(shouldIgnoreNextBeforeRemove.current||isDiscardModalOpen.current){clearShouldIgnoreNextBeforeRemove();window.history.go(1);// still revert the browser backreturn;}shouldNavigateBack.current=true;if(closing){window.history.go(1);return;}window.history.go(1);navigateAfterInteraction(showDiscardModal);});
This is safe because the suppression flag is already scoped to the post-cancel cleanup window (set inside .then() only when history.state.shouldGoBack === true, auto-cleared after 250ms), so legitimate future back gestures still show the discard modal. The isDiscardModalOpen.current check also protects the in-flight case where beforeRemove already queued showDiscardModal and transitionStart would otherwise stack a duplicate. Other consumers of the hook (IOURequestStepMerchant, IOURequestStepDescription, IOURequestStepDistanceOdometer, EditAgentAvatarPage) all rely on the same modal cleanup path, so they benefit from the fix without any per-caller change.
What alternative solutions did you explore? (Optional)
We considered making Modal/index.tsx skip the cleanup withInternalPopstate(() => window.history.back()) entirely when the modal closes via Cancel, but that would break global modals that legitimately rely on the shouldGoBack history entry to recover the URL state after dismissal — too broad. Another option was to gate showDiscardModal itself with an if (isDiscardModalOpen.current) return; early return, but that only blocks duplicate stacking — it doesn't address the post-cancel re-trigger where the flag was already reset to false by the .then() callback before transitionStart fires.
changed the title [-]mWeb - Avatar - Discard changes modal cannot be closed after swiping back and tapping Cancel[/-][+][$250] mWeb - Avatar - Discard changes modal cannot be closed after swiping back and tapping Cancel[/+]on Jun 5, 2026
⚠️@wildan-m Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.
🚨 Edited by proposal-police: This proposal was edited at 2026-06-19 11:36:28 UTC.
Proposal
What is the root cause of that problem?
This is iOS mWeb Safari only, and it's a release gap: the 9.3.99-9 build (tag SHA 4ba31d7) ships the olduseDiscardChangesConfirmation web hook that has no protection against a second beforeRemove firing after the user taps Cancel.
The Profile → Avatar screen renders inside an RHP modal and wires the discard guard with getHasUnsavedChanges: () => !isSavingRef.current && isDirty, where isDirty stays true for any selected/uploaded avatar — AvatarPage.tsx#L44-L48.
When that RHP modal opens, Modal.showModal pushes a history entry tagged {shouldGoBack: true}, and on close it defers a history.back() to reconcile it — Modal/index.tsx#L63-L92. The swipe-back gesture is a browser POP, so the history is mid-cleanup when the discard flow starts.
The break is in the web hook's useBeforeRemove handler — index.ts#L64-L71. Its only early-out is !getHasUnsavedChanges() || shouldNavigateBack.current; otherwise it calls e.preventDefault() + navigateAfterInteraction(showDiscardModal). The Cancel branch — index.ts#L56-L62 — only resets blockedNavigationAction/shouldNavigateBack and calls onCancel. It sets no flag to suppress the next event.
Tap Cancel → modal resolves, shouldNavigateBack reset to false, but the avatar is still selected so getHasUnsavedChanges() is still true.
The RHP modal's deferred history.back() / popstate reconciliation (the {shouldGoBack: true} entry) fires a secondbeforeRemove. It re-enters L64-71, passes the early-out, preventDefault()s and calls showDiscardModal()again → the modal immediately re-appears.
To the user, Cancel does nothing and the modal can't be dismissed. This is web-specific because the native hook (index.native.ts) doesn't use this popstate/transitionStart machinery.
The fix for exactly this symptom already exists on main (merged mid-May, commit b68f37c, preceded by 462b3d5/5ae96ba) but the 9.3.99-9 release branch diverged and doesn't contain it.
What changes do you think we should make in order to solve the problem?
Layer: the hook (src/hooks/useDiscardChangesConfirmation/index.ts). The render/modal layer is fine — the problem is the re-entrant beforeRemove.
Bring the guard that's already on main into this release. It adds two pieces:
An isDiscardModalOpen ref and a shouldIgnoreNextBeforeRemove ref. In useBeforeRemove, if either is set, preventDefault() and return without calling showDiscardModal — see index.ts#L93-L114 @ b68f37c.
markNextBeforeRemoveAsModalCleanup() (called in the modal's .then, before branching) which, only when window.history.state.shouldGoBack === true, arms shouldIgnoreNextBeforeRemove and auto-clears it after 250ms — index.ts#L34-L47 @ b68f37c and the call site at index.ts#L60-L72.
Net effect: the spurious post-cancel beforeRemove triggered by the RHP modal's history cleanup is swallowed instead of re-opening the discard modal, so Cancel returns the user to the avatar editor as expected. The shouldGoBack === true gate keys precisely on the RHP modal's guard entry, so non-RHP discard flows (e.g. central-pane) are unaffected, and the timeout prevents a stale flag from suppressing a legitimate later back press.
So the concrete ask is: cherry-pick / re-merge b68f37c (with its prerequisites) onto the 9.3.99 release, or confirm why it was excluded if the divergence was intentional.
What alternative solutions did you explore? (Optional)
Pass shouldHandleNavigationBack to the discard ConfirmModal so it manages its own history entry symmetrically with the RHP. Rejected: the discard modal is deliberately shown with only shouldIgnoreBackHandlerDuringTransition: true and no shouldHandleNavigationBack — index.ts#L36-L42. Adding a second {shouldGoBack} guard entry on top of the RHP's would create competing history.back() calls and a worse history tangle; the real defect is that the hook never suppresses the re-entrant beforeRemove, which is what the main fix addresses directly.
Gate on getHasUnsavedChanges() differently (e.g. clear isDirty on Cancel). Rejected: that would discard the user's selection, which is the opposite of what Cancel should do — the user explicitly chose to keep editing, so the data must stay dirty.
Activity
applause-bot commentedon Jun 5, 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/be0049962dc88df61a38b9b8e98b5bb8b38a7ba9efdb83d0fe2d2aa7c37de818
MelvinBot commentedon Jun 5, 2026
Proposal
What is the root cause of that problem?
The "Discard changes?" modal is opened by two different code paths in
useDiscardChangesConfirmation, and only one of them is guarded against re-entry.beforeRemoveevent (index.ts:93-114).popstate→ thetransitionStartlistener (index.ts:121-136). This is the path that shows the modal on swipe-back.When the user taps Cancel, the global Modal's
hideModalruns a deferredwindow.history.back()(Modal/index.tsx:63-80) to consume the synthetic{shouldGoBack: true}history entry it pushed when it opened. Thathistory.back()firespopstate, which makes RN firetransitionStartagain.The
transitionStartlistener has no re-entry guard — it only checksgetHasUnsavedChanges()(stilltrue, because Cancel correctly keeps the form dirty). So it immediately re-runswindow.history.go(1)+showDiscardModal()and the modal pops straight back up. The modal can never be dismissed. This is iOS mWeb Safari only because that is the only platform where the modal is opened viatransitionStartinstead ofbeforeRemove.The recent fix for the sibling issue #86585 (PR #89789) added the
shouldIgnoreNextBeforeRemove/markNextBeforeRemoveAsModalCleanupguard — but that guard is only consulted in thebeforeRemovepath (index.ts:100-104), never intransitionStart. That is why it fixed the header-back-button case but left the iOS swipe-back case broken.Step-by-step event timeline (swipe-back → Cancel)
popstate.transitionStart(closing: true). Listener setsshouldNavigateBack.current = true, callswindow.history.go(1)to undo the back.history.go(1)re-firestransitionStart(closing: false) → listener callsnavigateAfterInteraction(showDiscardModal)→ modal opens;Modal.showModalpushes a{shouldGoBack: true}history entry (Modal/index.tsx:82-92).Modal.hideModalschedulessetTimeout(0) → withInternalPopstate(() => history.back())..then()resolves:isDiscardModalOpen.current = false,shouldNavigateBack.current = false,onCancel()(index.ts:60-91).history.back()firespopstate→ RN firestransitionStartagain → listener has no guard → re-shows the modal. Loop.What changes do you think we should make in order to solve the problem?
Make the
transitionStartlistener ignore the navigation event that originates from the Modal's own internalhistory.back(), exactly the wayPopover/index.tsxalready does for this same class of re-entrancy.There is a purpose-built helper for this:
isInternalPopstateInProgress()— it returnstrueprecisely while the Modal'swithInternalPopstate(() => history.back())is running. At the top of thetransitionStartlistener inuseDiscardChangesConfirmation/index.ts:121-136, return early (withouthistory.go(1)orshowDiscardModal()) when the popstate is internal. This stops the Cancel-triggeredhistory.back()from re-opening the modal, while still reacting to genuine user swipe-backs.What alternative solutions did you explore? (Optional)
beforeRemoveguard: addif (isDiscardModalOpen.current || shouldIgnoreNextBeforeRemove.current) { return; }at the top of thetransitionStartlistener — reusing theshouldIgnoreNextBeforeRemoveflag thatmarkNextBeforeRemoveAsModalCleanupalready arms for ~250ms on Cancel. This works because the flag is armed before the deferredhistory.back()fires, but it is timing-dependent (250ms window); theisInternalPopstateInProgress()approach is deterministic and preferred.shouldHandleNavigationBack: falsefor the discard modal (explored in the closed PRs Disable modal navigation back handling for discard changes confirmation on mWeb #89391 and Fix confirm modal not showing (loops to Merchant page) #88250) — rejected previously because it breaks the Modal's history bookkeeping.Related issues
beforeRemovepath only by PR mWeb Expense: Fix discard modal not closing on cancel #89789. This issue is thetransitionStart(iOS swipe-back) gap that fix left open.transitionStart/history.go(1)machinery and is worth fixing together.Next Steps for Contributor+ team:
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/issues/92793)to create a draft PR.To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting Melvin's proposal.
MobileMage commentedon Jun 5, 2026
🚨 Edited by proposal-police: This proposal was edited at 2026-06-05 18:03:04 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
On mWeb Safari, after selecting an avatar on the Edit profile picture page, swiping back to trigger the Discard changes confirmation, and tapping Cancel, the modal briefly animates out and then immediately re-appears. It can never be dismissed via Cancel because each Cancel tap is followed by an instant re-open, leaving the user permanently stuck on the discard prompt.
What is the root cause of that problem?
The Discard changes flow on web is driven by
useDiscardChangesConfirmation, which listens to React Navigation'stransitionStartevent to detect browser-level back navigation (e.g. an iOS Safari swipe back) and reopen the page withwindow.history.go(1)while showing the confirm modal. The confirm modal itself is rendered throughuseConfirmModal->ConfirmModalWrapperwithshouldHandleNavigationBack: true, which makesModal/index.tsxpush an extra browser history entry taggedshouldGoBack: truewhen the modal opens and pop it back withwithInternalPopstate(() => window.history.back())when it closes:App/src/components/Modal/index.tsx
Lines 63 to 80 in bf59025
A recent fix (
markNextBeforeRemoveAsModalCleanup) was added precisely to prevent that cleanuphistory.back()from re-firing the discard modal, by settingshouldIgnoreNextBeforeRemove.current = truefor 250ms when the modal closes. The flag is consumed in theuseBeforeRemovehandler, which guards the in-app navigation path. But on mWeb Safari, the swipe back never goes throughbeforeRemove(the comment in the hook explicitly states: "We cannot programmatically stop the browser's back navigation like react-navigation's beforeRemove"). It goes throughtransitionStartinstead — and thetransitionStartlistener has no equivalent guard:App/src/hooks/useDiscardChangesConfirmation/index.ts
Lines 121 to 136 in bf59025
So the sequence on Cancel is: (1)
ConfirmModalWrapper.handleCancelflipsisVisibleto false, the modal animates out, andModal/index.tsx.hideModalscheduleswithInternalPopstate(() => window.history.back())in asetTimeout(0). (2) The hook's.then()runs, callingmarkNextBeforeRemoveAsModalCleanup()(setsshouldIgnoreNextBeforeRemove = true), resettingisDiscardModalOpen.current = false, and clearingshouldNavigateBack.current = false. (3) The deferredhistory.back()fires popstate; React Navigation'suseLinkingresets the root to the AvatarPage record, which emits a freshtransitionStartwhilegetHasUnsavedChanges()is still true (the avatar selection lives onselected/imageDatastate and was never cleared by Cancel). (4) ThetransitionStartlistener doesn't checkshouldIgnoreNextBeforeRemove.currentorisDiscardModalOpen.current, so it runswindow.history.go(1)and immediately callsnavigateAfterInteraction(showDiscardModal)again — pushing a brand-newConfirmModalWrapperonto the global modal stack:Visually this looks like Cancel "did nothing": the user's tap closes modal A, but modal B is pushed onto the stack in the same frame, and
ModalContextonly renders the topmost modal (modalStack.modals.at(-1)), so the prompt never disappears. Every subsequent Cancel just trades modal N for modal N+1.What changes do you think we should make in order to solve the problem?
Extend the existing modal-cleanup suppression so it also short-circuits the
transitionStartre-trigger, mirroring whatuseBeforeRemovealready does. The hook already ownsshouldIgnoreNextBeforeRemoveand the 250ms self-clearing timer set bymarkNextBeforeRemoveAsModalCleanup— we just need to honor it on the web back path too, and clear it on consumption so it doesn't leak into a real subsequent back gesture. We should also guard againstisDiscardModalOpen.currentto avoid the edge case where the initial swipe-back popstate chain queues twoshowDiscardModalcalls before the first one mounts.Concretely, in
src/hooks/useDiscardChangesConfirmation/index.ts, update thetransitionStartlistener to consume the cleanup flag and bail out, and avoid stacking a second modal:This is safe because the suppression flag is already scoped to the post-cancel cleanup window (set inside
.then()only whenhistory.state.shouldGoBack === true, auto-cleared after 250ms), so legitimate future back gestures still show the discard modal. TheisDiscardModalOpen.currentcheck also protects the in-flight case wherebeforeRemovealready queuedshowDiscardModalandtransitionStartwould otherwise stack a duplicate. Other consumers of the hook (IOURequestStepMerchant,IOURequestStepDescription,IOURequestStepDistanceOdometer,EditAgentAvatarPage) all rely on the same modal cleanup path, so they benefit from the fix without any per-caller change.What alternative solutions did you explore? (Optional)
We considered making
Modal/index.tsxskip the cleanupwithInternalPopstate(() => window.history.back())entirely when the modal closes via Cancel, but that would break global modals that legitimately rely on theshouldGoBackhistory entry to recover the URL state after dismissal — too broad. Another option was to gateshowDiscardModalitself with anif (isDiscardModalOpen.current) return;early return, but that only blocks duplicate stacking — it doesn't address the post-cancel re-trigger where the flag was already reset to false by the.then()callback beforetransitionStartfires.wildan-m commentedon Jun 5, 2026
🚫 Duplicated proposal withdrawn by 🤖 ProposalPolice.
melvin-bot commentedon Jun 5, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @abdulrahuman5196 (
External)[-]mWeb - Avatar - Discard changes modal cannot be closed after swiping back and tapping Cancel[/-][+][$250] mWeb - Avatar - Discard changes modal cannot be closed after swiping back and tapping Cancel[/+]melvin-bot commentedon Jun 5, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022062957626431734799
github-actions commentedon Jun 5, 2026
oqildev commentedon Jun 5, 2026
🚨 Edited by proposal-police: This proposal was edited at 2026-06-19 11:36:28 UTC.
Proposal
What is the root cause of that problem?
This is iOS mWeb Safari only, and it's a release gap: the
9.3.99-9build (tag SHA4ba31d7) ships the olduseDiscardChangesConfirmationweb hook that has no protection against a secondbeforeRemovefiring after the user taps Cancel.The Profile → Avatar screen renders inside an RHP modal and wires the discard guard with
getHasUnsavedChanges: () => !isSavingRef.current && isDirty, whereisDirtystaystruefor any selected/uploaded avatar — AvatarPage.tsx#L44-L48.When that RHP modal opens,
Modal.showModalpushes a history entry tagged{shouldGoBack: true}, and on close it defers ahistory.back()to reconcile it — Modal/index.tsx#L63-L92. The swipe-back gesture is a browserPOP, so the history is mid-cleanup when the discard flow starts.The break is in the web hook's
useBeforeRemovehandler — index.ts#L64-L71. Its only early-out is!getHasUnsavedChanges() || shouldNavigateBack.current; otherwise it callse.preventDefault()+navigateAfterInteraction(showDiscardModal). The Cancel branch — index.ts#L56-L62 — only resetsblockedNavigationAction/shouldNavigateBackand callsonCancel. It sets no flag to suppress the next event.So the sequence is:
beforeRemovefires → unsaved changes → discard modal shows.shouldNavigateBackreset tofalse, but the avatar is still selected sogetHasUnsavedChanges()is stilltrue.history.back()/ popstate reconciliation (the{shouldGoBack: true}entry) fires a secondbeforeRemove. It re-enters L64-71, passes the early-out,preventDefault()s and callsshowDiscardModal()again → the modal immediately re-appears.To the user, Cancel does nothing and the modal can't be dismissed. This is web-specific because the native hook (
index.native.ts) doesn't use this popstate/transitionStartmachinery.The fix for exactly this symptom already exists on
main(merged mid-May, commitb68f37c, preceded by462b3d5/5ae96ba) but the9.3.99-9release branch diverged and doesn't contain it.What changes do you think we should make in order to solve the problem?
Layer: the hook (
src/hooks/useDiscardChangesConfirmation/index.ts). The render/modal layer is fine — the problem is the re-entrantbeforeRemove.Bring the guard that's already on
maininto this release. It adds two pieces:isDiscardModalOpenref and ashouldIgnoreNextBeforeRemoveref. InuseBeforeRemove, if either is set,preventDefault()and return without callingshowDiscardModal— see index.ts#L93-L114 @ b68f37c.markNextBeforeRemoveAsModalCleanup()(called in the modal's.then, before branching) which, only whenwindow.history.state.shouldGoBack === true, armsshouldIgnoreNextBeforeRemoveand auto-clears it after 250ms — index.ts#L34-L47 @ b68f37c and the call site at index.ts#L60-L72.Net effect: the spurious post-cancel
beforeRemovetriggered by the RHP modal's history cleanup is swallowed instead of re-opening the discard modal, so Cancel returns the user to the avatar editor as expected. TheshouldGoBack === truegate keys precisely on the RHP modal's guard entry, so non-RHP discard flows (e.g. central-pane) are unaffected, and the timeout prevents a stale flag from suppressing a legitimate later back press.So the concrete ask is: cherry-pick / re-merge
b68f37c(with its prerequisites) onto the9.3.99release, or confirm why it was excluded if the divergence was intentional.What alternative solutions did you explore? (Optional)
Pass
shouldHandleNavigationBackto the discardConfirmModalso it manages its own history entry symmetrically with the RHP. Rejected: the discard modal is deliberately shown with onlyshouldIgnoreBackHandlerDuringTransition: trueand noshouldHandleNavigationBack— index.ts#L36-L42. Adding a second{shouldGoBack}guard entry on top of the RHP's would create competinghistory.back()calls and a worse history tangle; the real defect is that the hook never suppresses the re-entrantbeforeRemove, which is what themainfix addresses directly.Gate on
getHasUnsavedChanges()differently (e.g. clearisDirtyon Cancel). Rejected: that would discard the user's selection, which is the opposite of what Cancel should do — the user explicitly chose to keep editing, so the data must stay dirty.37 remaining items
melvin-bot commentedon Jul 1, 2026
@abdulrahuman5196 10 days overdue. Is anyone even seeing these? Hello?
mvtglobally commentedon Jul 3, 2026
Issue not reproducible during KI retests. (Third week)
melvin-bot commentedon Jul 3, 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 Jul 3, 2026
@abdulrahuman5196 this issue is now 4 weeks old, please consider:
Thanks!
melvin-bot commentedon Jul 3, 2026
@abdulrahuman5196 12 days overdue. Walking. Toward. The. Light...
melvin-bot commentedon Jul 4, 2026
@abdulrahuman5196 12 days overdue now... This issue's end is nigh!
melvin-bot commentedon Jul 6, 2026
This issue has not been updated in over 14 days. @abdulrahuman5196 eroding to Weekly issue.
melvin-bot commentedon Jul 10, 2026
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸
mvtglobally commentedon Jul 11, 2026
Issue not reproducible during KI retests. (Fourth week)
abdulrahuman5196 commentedon Jul 12, 2026
QA also not reproducing, asking in slack to close.