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-12-02] [$250] Web-Chat- Edit comment input is not focused #104360
Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor
Please re-state the problem that we are trying to solve in this issue.
After you delete a workspace, the "Edit comment" input does not get focus on a report opened from Spend > Reports.
What is the root cause of that problem?
Deleting a workspace leaves behind a "ready to focus" promise that never resolves. Every delayed composer focus then waits on it forever.
The delete-workspace confirm modal stays open with a loading state. Then closeModal() removes it from the global modal stack while it is still visible. This unmounts the modal instead of hiding it.
On unmount, BaseModal calls hideModal, but never ComposerFocusManager.setReadyToFocus(id). Only the visible→hidden path resolves the promise. So the modal's entry stays in promiseMap, unresolved.
focusComposerWithDelay waits on ComposerFocusManager.isReadyToFocus() with no id. With no id, it reads the last key in promiseMap. Later modals add and remove their own keys, so the leaked entry ends up last again.
In the RHP, ReportActionItemMessageEdit sets autoFocus={!shouldUseNarrowLayout}, which is false there. Its only focus path is the delayed focus on mount, which never runs.
Inbox chats on wide web still work because autoFocus is true there. The empty report doesn't matter. The deleted workspace is the trigger.
What changes do you think we should make in order to solve the problem?
In BaseModal, when the modal unmounts while still visible, also call ComposerFocusManager.setReadyToFocus(uniqueModalId) in the unmount cleanup. This fixes every global modal that closes while visible, not only delete-workspace.
What alternative solutions did you explore? (Optional)
Have ConfirmModalWrapper hide itself first (isVisible=false), then pop the stack in onModalHide, instead of unmounting while visible.
Add a timeout to the isReadyToFocus() wait in focusComposerWithDelay, so one leaked promise can't block focus for the whole session.
Confidence and verification
Confidence: Medium. The code path is confirmed. I could not reproduce it at runtime: on web, the test tool can't right-click, so it never reached "Edit comment". The empty report was created and the comment posted fine.
To confirm, test edit-comment in a fresh session where no workspace was deleted. This theory says it should focus there. In a session where a workspace was deleted, a non-empty report from Spend > Reports should also fail.
Next Steps for Contributor+ team: To accept:@MelvinBot implement [this](https://github.com/Expensify/App/issues/104360) to create a draft PR. To refine:@MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.
Please re-state the problem that we are trying to solve in this issue.
On Web, after deleting a workspace (or when any modal unmounts while visible), right-clicking a message in a report opened from Spend > Reports and selecting "Edit comment" fails to focus the edit comment composer input.
What is the root cause of that problem?
A leaked unresolved promise in ComposerFocusManager:
When a modal opens (onModalWillShow), BaseModal.tsx:359 calls saveFocusState(), which calls ComposerFocusManager.resetReadyToFocus(uniqueModalId) (BaseModal.tsx:133). This registers a pending promise in ComposerFocusManager.promiseMap (src/libs/ComposerFocusManager.ts:189-198).
In normal dismiss flows, handleDismissModal() runs in useEffect when !isVisible && wasVisible (BaseModal.tsx:174-176), invoking ComposerFocusManager.setReadyToFocus(uniqueModalId) which resolves and deletes the entry from promiseMap.
However, when a modal unmounts directly while still visible (such as during DeleteWorkspaceFlow when closeModal pops the modal stack while in a loading state):
The unmount effect runs (BaseModal.tsx:197-206):
This calls hideModalCallbackRef.current?.(true), which triggers hideModal() and calls ComposerFocusManager.refocusAfterModalFullyClosed(uniqueModalId, restoreFocusType) (BaseModal.tsx:152).
However, handleDismissModal() is never called because the !isVisible && wasVisible update effect never executes when unmounting directly.
As a result:
uniqueModalId remains permanently in promiseMap with an unresolved promise.
When entering edit comment mode, ReportActionItemMessageEdit.tsx:160 calls focusComposerWithDelay(composerRef.current)(true).
In src/libs/focusComposerWithDelay/index.ts:57, it awaits Promise.all([ComposerFocusManager.isReadyToFocus(), isWindowReadyToFocus()]).
ComposerFocusManager.isReadyToFocus() (called without arguments) invokes getTopmostModalId(), which returns the leaked modal ID from promiseMap.
This await hangs indefinitely, completely blocking composer focus.
Flaws in existing proposals:
MelvinBot noted the unmount path but did not address unmount effect dependencies or memory cleanup in ComposerFocusManager.
In React, putting [handleDismissModal] as a dependency on an unmount cleanup effect is a critical bug: the cleanup function fires on every render where handleDismissModal changes, resolving the focus promise prematurely while the modal is still mounted and open.
What changes do you think we should make in order to solve the problem?
In src/components/Modal/BaseModal.tsx:
Store uniqueModalId in a ref (or capture it cleanly) and invoke ComposerFocusManager.setReadyToFocus inside the unmount cleanup effect:
constuniqueModalIdRef=useRef(uniqueModalId);useEffect(()=>{uniqueModalIdRef.current=uniqueModalId;},[uniqueModalId]);useEffect(()=>()=>{if(!shouldCallHideModalOnUnmount.current){return;}hideModalCallbackRef.current?.(true);ComposerFocusManager.setReadyToFocus(uniqueModalIdRef.current);},// Keep empty dependency array so cleanup only runs when unmounting[],);
In src/libs/ComposerFocusManager.ts (Defense-in-depth):
In getTopmostModalId(), verify that the returned modal ID corresponds to an active modal; if the map holds dangling keys with no active modals, prune them so isReadyToFocus() never hangs indefinitely.
What specific scenarios should we cover in automated tests?
In tests/ui/BaseModalTest.tsx:
Render BaseModal with isVisible={true}.
Unmount the component directly while still visible.
Verify that ComposerFocusManager.isReadyToFocus() resolves immediately after unmount instead of hanging unresolved.
Please re-state the problem that we are trying to solve in this issue.
After deleting a workspace, opening a report from Spend > Reports and right-clicking a comment to "Edit comment" does not focus the comment input on web.
What is the root cause of that problem?
Deleting the workspace leaves a never-resolving "ready to focus" promise behind, and every delayed composer focus after that waits on it forever:
The delete-workspace confirm modal is closed via closeModal() while it is still in its loading state, which unmounts the modal instead of dismissing it.
BaseModal's handleDismissModal (which calls ComposerFocusManager.setReadyToFocus(uniqueModalId)) only runs on the visible-to-hidden path (isVisible && wasVisible). The unmount cleanup calls hideModal, which only calls ComposerFocusManager.refocusAfterModalFullyClosed - that waits on isReadyToFocus(id) and never resolves the promise itself. So the modal's entry leaks in promiseMap.
focusComposerWithDelay calls ComposerFocusManager.isReadyToFocus() with no id, which reads the last key in promiseMap via getTopmostModalId(). The leaked entry ends up last again, so delayed focus never fires.
In the RHP, ReportActionItemMessageEdit sets autoFocus={!shouldUseNarrowLayout} which is false there, so the delayed focus on mount is its only focus path - and it never runs.
Inbox chats on wide web still work because autoFocus is true there. The empty report and the deleted workspace are just the trigger, not the cause.
What changes do you think we should make in order to solve the problem?
In BaseModal, when the modal unmounts while it is still visible, also call ComposerFocusManager.setReadyToFocus(uniqueModalId) in the unmount cleanup. This fixes every global modal that closes while visible, not only the delete-workspace flow.
What alternative solutions did you explore?
Have ConfirmModalWrapper hide itself first (isVisible=false), then pop the modal stack in onModalHide, instead of unmounting while visible.
Add a timeout to the isReadyToFocus() wait in focusComposerWithDelay, so one leaked promise cannot block focus for the whole session.
What will I verify?
Delete a workspace, then open a report from Spend > Reports and right-click "Edit comment" on web: the input gets focus.
Normal modal dismiss focus-restore behavior is unchanged.
Add a unit test covering the unmount-while-visible path resolving the promise.
changed the title [-][$250] Web-Chat- Edit comment input is not focused[/-][+][Due for payment 2026-12-02] [$250] Web-Chat- Edit comment input is not focused[/+]on Nov 25, 2026
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.5.53-3 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
If no regressions arise, payment will be issued on 2026-12-02. 🎊
The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the Contributor+ Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]. If no checklist is needed for this issue, you can click: [no checklist button]
[Contributor] The offending PR and associated issue have been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.
Link to the comment on the PR: Couldn't find the PR as the issue is in the main Modal component which is present since a long time.
Link to the comment on the Issue: N/A
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion:
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
[BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
Link to issue:
Regression Test Proposal
Precondition:
Test:
Preconditions:
Create 2 workspaces
Delete 1 workspace without reloading the page or restarting the app afterwards
Steps:
Navigate to Spend > Reports
Click FAB
Click 'Create report'
Comment on the empty report
Right click on the comment (long press on mobile)
Click on 'Edit comment'
Verify that the input of the message you selected is in focus
Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor
Activity
applause-bot commentedon Oct 19, 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/d8325cff8e01e345bb4135539346d6690f60b2b78e100510d034efea4654e9e8
MelvinBot commentedon Oct 19, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
After you delete a workspace, the "Edit comment" input does not get focus on a report opened from Spend > Reports.
What is the root cause of that problem?
Deleting a workspace leaves behind a "ready to focus" promise that never resolves. Every delayed composer focus then waits on it forever.
closeModal()removes it from the global modal stack while it is still visible. This unmounts the modal instead of hiding it.BaseModalcallshideModal, but neverComposerFocusManager.setReadyToFocus(id). Only the visible→hidden path resolves the promise. So the modal's entry stays inpromiseMap, unresolved.focusComposerWithDelaywaits onComposerFocusManager.isReadyToFocus()with no id. With no id, it reads the last key inpromiseMap. Later modals add and remove their own keys, so the leaked entry ends up last again.ReportActionItemMessageEditsetsautoFocus={!shouldUseNarrowLayout}, which isfalsethere. Its only focus path is the delayed focus on mount, which never runs.Inbox chats on wide web still work because
autoFocusistruethere. The empty report doesn't matter. The deleted workspace is the trigger.Code references
setReadyToFocus: BaseModal.tsx:197-206, compared with the dismiss path at BaseModal.tsx:173-176hideModalwaits on the same unresolved promise: BaseModal.tsx:152isReadyToFocus()with no id uses the last key: ComposerFocusManager.ts:189-231What changes do you think we should make in order to solve the problem?
In
BaseModal, when the modal unmounts while still visible, also callComposerFocusManager.setReadyToFocus(uniqueModalId)in the unmount cleanup. This fixes every global modal that closes while visible, not only delete-workspace.What alternative solutions did you explore? (Optional)
ConfirmModalWrapperhide itself first (isVisible=false), then pop the stack inonModalHide, instead of unmounting while visible.isReadyToFocus()wait infocusComposerWithDelay, so one leaked promise can't block focus for the whole session.Confidence and verification
Confidence: Medium. The code path is confirmed. I could not reproduce it at runtime: on web, the test tool can't right-click, so it never reached "Edit comment". The empty report was created and the comment posted fine.
To confirm, test edit-comment in a fresh session where no workspace was deleted. This theory says it should focus there. In a session where a workspace was deleted, a non-empty report from Spend > Reports should also fail.
Next Steps for Contributor+ team:
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/issues/104360)to create a draft PR.To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting Melvin's proposal.
view run · view recording
melvin-bot commentedon Oct 19, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @parasharrajat (
External)[-]Web-Chat- Edit comment input is not focused[/-][+][$175] Web-Chat- Edit comment input is not focused[/+]melvin-bot commentedon Oct 19, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022112190878495307640
camesenin commentedon Oct 19, 2026
melvin-bot commentedon Oct 19, 2026
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
azhumide commentedon Oct 19, 2026
Contributor details
Your Expensify account email: azhumide@gmail.com
Upwork Profile Link: https://www.upwork.com/freelancers/~01096eb540e2a8e9a5
Proposal
Please re-state the problem that we are trying to solve in this issue.
On Web, after deleting a workspace (or when any modal unmounts while visible), right-clicking a message in a report opened from Spend > Reports and selecting "Edit comment" fails to focus the edit comment composer input.
What is the root cause of that problem?
A leaked unresolved promise in
ComposerFocusManager:When a modal opens (
onModalWillShow),BaseModal.tsx:359callssaveFocusState(), which callsComposerFocusManager.resetReadyToFocus(uniqueModalId)(BaseModal.tsx:133). This registers a pending promise inComposerFocusManager.promiseMap(src/libs/ComposerFocusManager.ts:189-198).In normal dismiss flows,
handleDismissModal()runs inuseEffectwhen!isVisible && wasVisible(BaseModal.tsx:174-176), invokingComposerFocusManager.setReadyToFocus(uniqueModalId)which resolves and deletes the entry frompromiseMap.However, when a modal unmounts directly while still visible (such as during
DeleteWorkspaceFlowwhencloseModalpops the modal stack while in a loading state):The unmount effect runs (
BaseModal.tsx:197-206):This calls
hideModalCallbackRef.current?.(true), which triggershideModal()and callsComposerFocusManager.refocusAfterModalFullyClosed(uniqueModalId, restoreFocusType)(BaseModal.tsx:152).However,
handleDismissModal()is never called because the!isVisible && wasVisibleupdate effect never executes when unmounting directly.As a result:
uniqueModalIdremains permanently inpromiseMapwith an unresolved promise.ReportActionItemMessageEdit.tsx:160callsfocusComposerWithDelay(composerRef.current)(true).src/libs/focusComposerWithDelay/index.ts:57, it awaitsPromise.all([ComposerFocusManager.isReadyToFocus(), isWindowReadyToFocus()]).ComposerFocusManager.isReadyToFocus()(called without arguments) invokesgetTopmostModalId(), which returns the leaked modal ID frompromiseMap.awaithangs indefinitely, completely blocking composer focus.Flaws in existing proposals:
ComposerFocusManager.cameseninproposed:[handleDismissModal]as a dependency on an unmount cleanup effect is a critical bug: the cleanup function fires on every render wherehandleDismissModalchanges, resolving the focus promise prematurely while the modal is still mounted and open.What changes do you think we should make in order to solve the problem?
src/components/Modal/BaseModal.tsx:uniqueModalIdin a ref (or capture it cleanly) and invokeComposerFocusManager.setReadyToFocusinside the unmount cleanup effect:src/libs/ComposerFocusManager.ts(Defense-in-depth):getTopmostModalId(), verify that the returned modal ID corresponds to an active modal; if the map holds dangling keys with no active modals, prune them soisReadyToFocus()never hangs indefinitely.What specific scenarios should we cover in automated tests?
In
tests/ui/BaseModalTest.tsx:BaseModalwithisVisible={true}.ComposerFocusManager.isReadyToFocus()resolves immediately after unmount instead of hanging unresolved.melvin-bot commentedon Oct 19, 2026
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
khizzcr7 commentedon Oct 19, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
After deleting a workspace, opening a report from Spend > Reports and right-clicking a comment to "Edit comment" does not focus the comment input on web.
What is the root cause of that problem?
Deleting the workspace leaves a never-resolving "ready to focus" promise behind, and every delayed composer focus after that waits on it forever:
closeModal()while it is still in its loading state, which unmounts the modal instead of dismissing it.BaseModal'shandleDismissModal(which callsComposerFocusManager.setReadyToFocus(uniqueModalId)) only runs on the visible-to-hidden path (isVisible && wasVisible). The unmount cleanup callshideModal, which only callsComposerFocusManager.refocusAfterModalFullyClosed- that waits onisReadyToFocus(id)and never resolves the promise itself. So the modal's entry leaks inpromiseMap.focusComposerWithDelaycallsComposerFocusManager.isReadyToFocus()with no id, which reads the last key inpromiseMapviagetTopmostModalId(). The leaked entry ends up last again, so delayed focus never fires.ReportActionItemMessageEditsetsautoFocus={!shouldUseNarrowLayout}which isfalsethere, so the delayed focus on mount is its only focus path - and it never runs.Inbox chats on wide web still work because
autoFocusistruethere. The empty report and the deleted workspace are just the trigger, not the cause.What changes do you think we should make in order to solve the problem?
In
BaseModal, when the modal unmounts while it is still visible, also callComposerFocusManager.setReadyToFocus(uniqueModalId)in the unmount cleanup. This fixes every global modal that closes while visible, not only the delete-workspace flow.What alternative solutions did you explore?
ConfirmModalWrapperhide itself first (isVisible=false), then pop the modal stack inonModalHide, instead of unmounting while visible.isReadyToFocus()wait infocusComposerWithDelay, so one leaked promise cannot block focus for the whole session.What will I verify?
81 remaining items
[-][$250] Web-Chat- Edit comment input is not focused[/-][+][Due for payment 2026-12-02] [$250] Web-Chat- Edit comment input is not focused[/+]melvin-bot commentedon Nov 25, 2026
@parasharrajat
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.5.53-3 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
If no regressions arise, payment will be issued on 2026-12-02. 🎊
The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the Contributor+ Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]. If no checklist is needed for this issue, you can click: [no checklist button]
expensify-chore-bot commentedon Dec 1, 2026
Triggered auto assignment to @mallenexpensify (
Awaiting Payment)expensify-chore-bot commentedon Dec 1, 2026
Payment Summary
Resolving PRs:
Upwork Job
BugZero Checklist (@mallenexpensify)
mallenexpensify commentedon Dec 3, 2026
Matt's AI agent:
Prep notes for the CM. This is not a payment approval. Do not request payment until the CM posts the final amount.
Waiting on C+ checklist from @parasharrajat.
Job price: $250.
Price basis: Help Wanted.
Next: wait for the C+ checklist.
Evidence
PAYPREP v1parasharrajat commentedon Dec 3, 2026
BugZero Checklist:
[Contributor] The offending PR and associated issue have been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.
Link to the comment on the PR: Couldn't find the PR as the issue is in the main Modal component which is present since a long time.
Link to the comment on the Issue: N/A
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion:
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
[BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
Link to issue:
Regression Test Proposal
Precondition:
Test:
Preconditions:
Steps:
Do we agree 👍 or 👎