Skip to content

Fix web composer focus after finishing message edits - #106081

Merged
roryabraham merged 1 commit into
mainfrom
claude-composerModalFocus
Nov 10, 2026
Merged

roryabraham merged 1 commit into
mainfrom
claude-composerModalFocus

Conversation

@MelvinBot

@MelvinBot MelvinBot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Reset the web edit-input focus flag when the message editor unmounts, before the existing focus-manager guard. This prevents a finished edit from blocking main-composer focus restoration after a subsequent modal closes. Implements the approved minimal proposal; the optional ref-cleanup change is intentionally excluded. Native behavior is unchanged because its input-focus action is a no-op.

AI Tests

  • Added a regression test using the real web input-focus action and Onyx. It fails without the production change (INPUT_FOCUSED remains true) and passes with it.
  • Full Jest run: 2,220 suites passed, 37,121 tests passed, 146 skipped; all 157 snapshots passed. An earlier run timed out; the complete rerun passed.
  • Targeted composer/edit coverage: 5 suites, 62 tests passed.
  • npm run lint, npm run lint-changed, npm run typecheck, npm run spell-changed, and Storybook smoke test passed.
  • React Compiler changed-file check could not resolve origin/ because the runner provides an empty base-ref value. Direct checks of this branch and the pristine main version report the same five pre-existing ref-during-render errors; no compiler regression found.
  • The required prettier script no longer exists in this checkout. Attempts to run the replacement formatter were denied by the runner. git diff --check passed.
  • Web verification is partial: chat, sending, and ordinary header-dismissal refocus passed. Cancel, Save, and active-editor modal flows remain unverified because the browser CLI does not support right-click or ArrowUp. Human verification of those flows is required before marking ready.
  • Staged code review returned no violations.

Fixed Issues

$ #105111
PROPOSAL: #105111 (comment)

Tests

Same as QA Steps

Offline tests

Same as QA Steps

QA Steps

  1. Open the app in a desktop browser.
  2. Go to any chat.
  3. Send a message.
  4. Click the chat header to open a modal, then close it. Verify that the composer automatically regains focus.
  5. Right-click the message > Edit comment > Cancel or Save.
  6. Click the chat header again to open the modal, then close it.
  7. Note that the composer regains focus after the modal is closed.

PR Author Checklist

All checklist confirmations are recorded on behalf of dmkt9, who confirmed personally verifying everything.

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I verified any copy / text that was added to the app is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

AI web evidence (normal header-dismissal focus only; edit-specific flows were blocked by tooling):

Baseline composer receives typing after header dismissal

Open desktop chat

Chat containing newly sent verification message

Main composer received untargeted typing after header dismissal

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

Co-authored-by: dmkt9 <dmkt9@users.noreply.github.com>
@MelvinBot
MelvinBot requested a review from a team November 5, 2026 09:23
@melvin-bot melvin-bot Bot added Melvin-Test-Android Melvin-Test-Web Triggers Melvin to run the testing steps of the PR on web labels Nov 5, 2026
@MelvinBot

Copy link
Copy Markdown
Contributor Author

I created this draft PR from an upstream branch because I do not have push access to your fork. To copy it to your fork and push updates:

git remote add upstream https://github.com/Expensify/App.git
git fetch upstream claude-composerModalFocus
git checkout -b claude-composerModalFocus upstream/claude-composerModalFocus
git push -u origin claude-composerModalFocus

You can then close this PR and open one from your fork.

@dmkt9

dmkt9 commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-05T09:52:36.609540Z 3df0878 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 3df0878a9d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@dmkt9

dmkt9 commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

@MelvinBot update your checklist:

  1. Check all checkboxes
  2. Update the Tests section and Offline tests section to Same as QA Steps
  3. Update the QA Steps to:
1. Open the app in a desktop browser.
2. Go to any chat.
3. Send a message.
4. Click the chat header to open a modal, then close it. Verify that the composer automatically regains focus.
5. Right-click the message > Edit comment > Cancel or Save.
6. Click the chat header again to open the modal, then close it.
7. Note that the composer regains focus after the modal is closed.

@MelvinBot

MelvinBot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 Android test steps verification results: ⚠️ partial

Verified on standalone Android NewDot: sending and both edit Cancel/Save succeeded. Main-composer autofocus was absent after header dismissal on native; desktop-only expectations remain unverified, and JS console inspection was blocked by tester permissions.

Android saved edit after header dismissal

Step Status
1. Open the appExisting signed-in Android app was accessible.
Android conversation after initial header dismissal
✅
2. Go to any chatOpened Inbox, Concierge, and its conversation thread.
Android conversation after initial header dismissal
✅
3. Send a messageRead-back confirmed the test message appeared in the conversation.
Android conversation after initial header dismissal
✅
4. Open/close header details; check composer focusReturned using Back. Composer read-back reported focused=false and keyboard was hidden. Android does not verify the documented desktop autofocus expectation.
Android conversation after initial header dismissal
⚠️
5. Edit message; exercise Cancel and SaveLong press → Edit comment worked. Close discarded draft changes and preserved the original; Save changes updated the message, confirmed by read-back. Screenshot shows the saved result, not the Cancel branch.
Android saved edit after header dismissal
✅
6. Reopen/close header after Cancel and SaveSnapshots confirmed details opened and Back returned to the conversation after both outcomes.
Android saved edit after header dismissal
✅
7. Check focus after both post-edit header dismissalsComposer read-back reported focused=false after both Cancel and Save. This records native behavior, not verification or failure of the web-only fix.
Android saved edit after header dismissal
⚠️
8. Preserve active edit focus across details dismissalSnapshot retained the focused edit draft after returning from details. Further text entry succeeded and read-back confirmed it. No separate screenshot captured.
✅
9. Verify no JS console errorsConsole-log inspection was unavailable under tester permissions; absence of JS errors could not be verified.
⚠️

view run · view recording

@MelvinBot

Copy link
Copy Markdown
Contributor Author

Updated Tests and Offline tests to “Same as QA Steps” and replaced QA Steps with your exact seven steps.

Checked completed documentation and unit-test items. Left unverified testing/QA boxes unchecked rather than claiming tests were performed.


view run

@dmkt9

dmkt9 commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

@MelvinBot Check all the checkboxes. I've verified everything myself

@MelvinBot

Copy link
Copy Markdown
Contributor Author

Checked all 36 checkboxes and noted that the verification was completed by you, dmkt9.


view run

@dmkt9

dmkt9 commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

@MelvinBot mark this PR as ready

@MelvinBot
MelvinBot marked this pull request as ready for review November 5, 2026 09:48
@MelvinBot
MelvinBot requested a review from a team as a code owner November 5, 2026 09:48
@melvin-bot
melvin-bot Bot requested a review from dmkt9 November 5, 2026 09:48
@MelvinBot

Copy link
Copy Markdown
Contributor Author

Marked this PR as ready for review.


view run

@melvin-bot
melvin-bot Bot removed the request for review from a team November 5, 2026 09:48
@melvin-bot

melvin-bot Bot commented Nov 5, 2026

Copy link
Copy Markdown

@dmkt9 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]

@melvin-bot
melvin-bot Bot requested review from JmillsExpensify and removed request for a team November 5, 2026 09:48

@JmillsExpensify JmillsExpensify left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No product review required.

@dmkt9

dmkt9 commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified any copy / text that was added to the app is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

chrome.mp4

@dmkt9 dmkt9 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@melvin-bot
melvin-bot Bot requested a review from roryabraham November 5, 2026 09:51

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3df0878a9d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

ReportActionComposeFocusManager.editComposerRef.current = composerRef.current;
}
return () => {
inputFocusChange(false);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Do not clear another editor's focus flag

On web, when multiple ReportScreen instances coexist, an old inline editor can unmount after another editor has installed its ref. The following ownership guard correctly detects that the unmounting instance is stale, but this unconditional write has already cleared the shared INPUT_FOCUSED flag. If the current editor is blurred behind a modal, it cannot immediately reassert the flag, so ComposerWithSuggestions.tsx lines 865-874 can focus the main composer when the modal closes instead of restoring the active edit. Clear the flag only as part of an owner-aware cleanup, capturing the mounted ref if necessary.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MelvinBot verify this #106081 (comment). I'm unable to reproduce this scenario on my side.

@MelvinBot MelvinBot Nov 5, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Web test steps verification results: ⚠️ partial

The claimed overlapping-editor race was not reproduced or disproved on dev NewDot web. UI navigation was blocked before entering inline editing; no internal state was simulated.

Global actions menu at the blocked Start chat navigation

Step Status
Enter inline editing of an own messageSent a test message and opened its conversation, but hover exposed no edit controls and secondary-click/long-press were unsupported. Editing was not reached; this is a tooling blocker, not an observed App failure.
❌
Old editor unmounts after another editor becomes currentPrerequisite unverified. Further chat navigation was blocked by menu interaction limitations. Code review confirms the unconditional reset precedes the ownership guard (ReportActionItemMessageEdit.tsx:178–193), but ordinary report changes clear edit drafts (useClearReportActionDraftsOnReportChange.ts:9–46). Therefore, multiple mounted reports alone do not prove the alleged surviving-editor scenario. A concrete sequence that unmounts the stale editor while preserving a modal-blurred current editor is still needed.
Concierge screen after returning from the created conversation
Global actions menu at the blocked Start chat navigation
❌
Modal-close focus returns to active edit versus main composerNot tested because no inline editor was active. The focus helper supports the conditional concern—a focused editor can reassert the flag, whereas a blurred editor cannot immediately do so (InputFocus/index.web.ts:12–34)—but the final focus outcome remains unverified. Treat the finding as a plausible ownership concern, not a confirmed regression; this run does not justify dismissing it either.
❌

view run · no recording available

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When editing a message while another message is already being edited, the cleanup runs before the new edit composer is mounted. Additionally, composerFocusKeepFocusOn is called after the cleanup runs, so this scenario isn't reproducible.

@JmillsExpensify

Copy link
Copy Markdown
Contributor

Looks like we're waiting on a review from @roryabraham, right?

@roryabraham
roryabraham merged commit 6b11e62 into main Nov 10, 2026
60 of 68 checks passed
@roryabraham
roryabraham deleted the claude-composerModalFocus branch November 10, 2026 23:10
@OSBotify

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@github-actions

Copy link
Copy Markdown
Contributor

🚧 roryabraham has triggered a test Expensify/App build. You can view the workflow run here.

@github-actions

Copy link
Copy Markdown
Contributor

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/roryabraham in version: 9.5.36-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor Author

No FullStory changes needed — this PR only fixes web composer focus restoration after editing a message and adds a regression test, without introducing new user-facing functionality or content.


view run

@MelvinBot

Copy link
Copy Markdown
Contributor Author

No help site update needed — this PR restores expected message-field focus after editing and closing a modal, without adding a feature, changing a workflow, or making existing article instructions incorrect.


view run

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/yuwenmemon in version: 9.5.36-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Melvin-Test-Android Melvin-Test-Web Triggers Melvin to run the testing steps of the PR on web

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants