Repository navigation
Fix stuck MFA cancel-confirm modal by not intercepting outside clicks - #93281
Conversation
The MFA screens overrode allowOutsideClick and clickOutsideDeactivates to intercept outside clicks at the document level (requestCancel + swallow the event). Once the modal's own focus trap deactivated, the still-active screen trap treated every click on the portal-rendered cancel-confirm modal as an outside click and swallowed it, leaving the modal impossible to close. Keep only the Escape override and let outside clicks follow the default focus-trap behavior (deactivate the trap and pass through, like RHP screens): they reach the MFA navigator's backdrop pressable, which requests the cancel flow, and the modal stays fully interactive.
An outside click deactivates the screen trap by design (RHP behavior), which left Tab able to move focus outside the MFA panel for the rest of the screen's lifetime. Drive the trap's active prop from the cancel-confirmation visibility: the trap is off while the modal is up (so it can't swallow the modal's clicks) and the prop flip on close reactivates it.
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
|
@abdulrahuman5196 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] |
Reviewer Checklist
Screenshots/VideosMacOS: Chrome / Safarimfa.cancel.confirm.modal.mp4 |
chuckdries
left a comment
There was a problem hiding this comment.
I am impressed with how straightforward this solution is! When I was poking the bug yesterday I worried it would be a huge mess to solve.
I will note that in the troubleshoot flow, pressing escape on the prompt page causes the cancel modal to flash open then closed, but this behavior reproduces on main in my testing so we'll solve it in a different PR.
Also, I updated the QA steps to mention the troubleshoot flow so they can actually execute them 😄
|
🚧 @chuckdries has triggered a test Expensify/App build. You can view the workflow run here. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/chuckdries in version: 9.4.6-0 🚀
Bundle Size Analysis (Sentry): |
|
🤖 Help site review: no docs changes required I reviewed the changes in this PR against the help site content under Conclusion: No updates are needed to Expensify's help site files. Why: This PR is a purely internal focus-trap interaction fix on the MFA screens (
The only related help articles (New Expensify Two-Factor Authentication and its Expensify Classic counterpart) document how to enable and use 2FA, not the internal modal/focus-trap behavior this PR fixes, so they remain accurate as-is. Since no changes are required, I did not create a draft help site PR. @dariusz-biela, please confirm you agree no help-site updates are needed for this change. If you believe a doc should be updated, let me know which behavior to document and I'll draft it. |
|
🚀 Deployed to production by https://github.com/Julesssss in version: 9.4.6-4 🚀
|
Explanation of Change
Problem
During an MFA flow (e.g. revealing virtual card details), clicking the dimmed area outside the MFA panel opens the cancel confirmation modal. After clicking outside that modal, the modal gets stuck: its buttons, backdrop and Escape stop responding, and only a page refresh recovers the app.
Cause
The MFA screens (magic code, prompt) overrode
allowOutsideClickandclickOutsideDeactivateson their focus trap to intercept outside clicks at the document level (callrequestCanceland swallow the event). The confirmation modal renders in a portal outside the screen trap's container, so it relies on its ownFocusTrapForModal, which pauses the screen trap while active. Once the modal's trap deactivated (a click outside the modal does that by design), the screen trap resumed and treated every click aimed at the modal as an outside click - swallowing it before React could deliver the press.Solution
The screens keep only the
escapeDeactivatesoverride (Escape still routes throughrequestCancel) and let outside clicks follow the default focus-trap behavior: the trap deactivates and the click passes through. The click then reaches the MFA navigator's backdrop pressable, which requests the cancel flow - so outside clicks still open the confirmation modal, and the modal stays fully interactive because no active trap can swallow its clicks anymore.Focus trap reactivation
An outside click deactivates the screen's focus trap by design (same as RHP screens). Since every outside click opens the cancel confirmation modal, the screens drive the trap with
active: isCancelConfirmVisible ? false : undefined- the trap is off while the modal is up (so it can't swallow the modal's clicks) and the prop flip on close reactivates it, keeping Tab contained in the MFA panel for the whole flow.Fixed Issues
$ #93193
PROPOSAL:
Tests
On web with a wide window, go to account > troubleshoot > Biometrics, press revoke if it is visible
Start the flow by pressing Biometrics > test - the MFA panel opens with the magic code screen
Click the dimmed area outside the MFA panel
Verify that the cancel confirmation modal appears
Click the dimmed backdrop around the confirmation modal
Verify that the modal closes (previously it stayed visible with unresponsive buttons)
Click outside the MFA panel again to reopen the confirmation modal
Click the modal's cancel ("No") button and verify the modal closes and the magic code screen stays interactive (typing in the input works)
Click outside the panel once more and click the confirm ("Yes") button - verify the whole MFA flow closes
With the magic code screen open, press Escape
Verify that the cancel confirmation modal appears and both its buttons work
Offline tests
N/A - the change only affects focus-trap behavior on web; no API or data changes.
QA Steps
Same as tests.
// TODO: These must be filled out, or the issue title must include "[No QA]."
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, 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.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Screen.Recording.2026-06-11.at.15.21.16.mp4