Skip to content

Chat-Compose box is not focused when starting a brand new chat #81609

Closed

Description

@mitarachim

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 9.3.15-0
Reproducible in staging?: Yes
Reproducible in production?: No
If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://test-management.browserstack.com/projects/2219752/folder/13176933/test-cases/41237724
Email or phone of affected tester (no customers): N/A
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: MacBook Air 15.7.3 Chrome
App Component: Chat Report View

Action Performed:

  1. Sign in to ND
  2. Click FAB - Start chat - enter email address of a user who you never interacted with
  3. When navigated to a new chat, observe the compose box

Expected Result:

Compose box is focused in a new chat

Actual Result:

Compose box is not focused when creating a new chat

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari

Screenshots/Videos

Bug7068818_1770329902016.New_chat_not_focused.mp4

View all open jobs on GitHub

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    DeployBlockerIndicates it should block deploying the API
    on Feb 5, 2026
  2. melvin-bot commented on Feb 5, 2026

    @melvin-bot

    Triggered auto assignment to @greg-schroeder (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

  3. melvin-bot commented on Feb 5, 2026

    @melvin-bot

    Triggered auto assignment to @mjasikowski (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

  4. melvin-bot commented on Feb 5, 2026

    @melvin-bot

    💬 A slack conversation has been started in #expensify-open-source

  5. github-actions commented on Feb 5, 2026

    @github-actions
    Contributor

    👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

    1. Identify the pull request that introduced this issue and revert it.
    2. Find someone who can quickly fix the issue.
    3. Fix the issue yourself.
  6. OSBotify commented on Feb 5, 2026

    @OSBotify
    Contributor

    Investigation Summary

    Classification: Frontend bug
    Causing PR: #80478 - "fix: update RNKC and RNPV to latest versions" by @kirillzyusko (High confidence)
    Related Issues: None directly linked

    Recommendation: REVERT

    The causing PR updated react-native-keyboard-controller from 1.18.5 to 1.20.6 and react-native-pager-view from 7.0.2 to 8.0.0. These are significant version jumps in libraries that directly control keyboard behavior and focus management. The timing matches perfectly - PR merged Feb 3, 2026, and the bug appeared in staging (9.3.15-0) but is NOT reproducible in production, confirming the issue was introduced in this deploy cycle.

    Labels: Keeping DeployBlockerCash (affects App), removing DeployBlocker (not a backend issue)

    Detailed Analysis

    Evidence

    • PR fix: update RNKC and RNPV to latest versions #80478 updated two critical dependencies for keyboard/focus management
    • Merged on 2026-02-03, which aligns with the 9.3.15-0 deploy
    • Bug is staging-only (not in production), indicating it was introduced in this deploy cycle
    • The symptom (compose box not auto-focusing on new chat) is directly related to keyboard controller behavior
    • PR was specifically intended to "fix missing keyboard animations" but may have introduced a regression

    Verification

    • The affected component is ReportActionCompose.tsx which uses keyboard controller features
    • Focus logic in ComposerWithSuggestions.tsx line 278:
      const shouldAutoFocus = 
        (shouldFocusInputOnScreenFocus || !!draftComment) && 
        shouldShowComposeInput && 
        areAllModalsHidden() && 
        isFocused && 
        !didHideComposerInput && 
        !shouldDisableAutoFocus;
    • The keyboard controller update changed the underlying focus behavior that this logic depends on

    Root Cause

    The react-native-keyboard-controller library (updated from 1.18.5 to 1.20.6 - a ~12 minor version jump) likely changed how it handles automatic focus when navigating to new screens. This broke the expected auto-focus behavior when creating a brand new chat with a user you have never interacted with.

    The MacOS Chrome/Safari specificity suggests a web platform regression in the new keyboard controller version.

  7. 2 remaining items

  8. OSBotify commented on Feb 5, 2026

    @OSBotify
    Contributor

    Investigation Summary

    Classification: Frontend bug
    Causing PR: #80606 - "Fix navigation race condition when closing Wide RHP after the deletion of last transaction" by @collectioneur (High confidence)
    Related Issues: None directly linked

    Recommendation: REVERT

    The causing PR modified the web Modal component to delay when onModalHide() is called - it now waits for the popstate event after window.history.back() instead of calling it immediately. This timing change creates a race condition where the composer tries to auto-focus before the modal hide callback completes, causing areAllModalsHidden() to return false and preventing auto-focus.

    The issue is staging-only (not in production), confirmed by the version number 9.3.15-0, and specifically affects MacOS Chrome/Safari (web platforms), which aligns perfectly with PR #80606 modifying the web-specific Modal component (src/components/Modal/index.tsx).

    Labels: Keeping DeployBlockerCash (affects App frontend), will remove DeployBlocker if present (not a backend issue)

    Detailed Analysis

    Evidence

    Verification

    The auto-focus logic in ComposerWithSuggestions.tsx line 277-278:

    const shouldAutoFocus =
        (shouldFocusInputOnScreenFocus || !!draftComment) && shouldShowComposeInput && areAllModalsHidden() && isFocused && !didHideComposerInput && !shouldDisableAutoFocus;

    The areAllModalsHidden() function in src/libs/actions/Modal.ts line 102-104:

    function areAllModalsHidden() {
        return closeModals.length === 0;
    }

    PR #80606 changed src/components/Modal/index.tsx (web only):

     const hideModal = () => {
    -    onModalHide();
         if ((window.history.state as WindowState)?.shouldGoBack && shouldHandleNavigationBack) {
    +        // Wait for history.back() to complete before calling onModalHide to prevent navigation race conditions
    +        window.addEventListener('popstate', onModalHide, {once: true});
             window.history.back();
    +    } else {
    +        onModalHide();
         }
     };

    Root Cause

    When creating a new chat on web, the user flow involves:

    1. Click FAB > Start chat (opens RHP/modal interface)
    2. Enter email and navigate to the new chat
    3. Modal/RHP begins to close, triggering hideModal()
    4. Navigation to new chat report happens
    5. Composer mounts and checks shouldAutoFocus

    Before PR #80606: onModalHide() was called immediately, so by the time the composer checked areAllModalsHidden(), it returned true, allowing auto-focus.

    After PR #80606: onModalHide() is deferred until after the popstate event, creating a timing window where the composer checks areAllModalsHidden() while the modal is still registered in the closeModals array, causing it to return false and preventing auto-focus.

    The PR intended to fix a race condition for RHP closing after transaction deletion, but inadvertently created a new race condition affecting composer auto-focus when navigating to new chats.

  9. mountiny commented on Feb 6, 2026

    @mountiny
    Contributor

    Testing this revert #81617

  10. mountiny commented on Feb 6, 2026

    @mountiny
    Contributor
  11. m-natarajan commented on Feb 6, 2026

    @m-natarajan

    Unable to repro, Win 11/Chrome, v9.3.15-0 PR:81617

    Recording.2356.mp4
  12. mountiny commented on Feb 6, 2026

    @mountiny
    Contributor

    Thanks cping the revert

  13. added and removed
    DeployBlockerCashThis issue or pull request should block deployment
    on Feb 6, 2026
  14. mountiny commented on Feb 6, 2026

    @mountiny
    Contributor

    cc @collectioneur we had to revert the pr due to this bug

    Confirmed in staging this is fixed

  15. collectioneur commented on Feb 9, 2026

    @collectioneur
    Contributor

    @mountiny Understood 😔. I'm investigating the root cause and will prepare a fix.

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

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2EngineeringReviewingHas a PR in review

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions