Skip to content

[Due for payment 2025-12-04] [$250] Conversation - Cursor not auto-focused in composer when returning to chat with draft #67029

Closed

Description

@jponikarchuk

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.1.85-2
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from TestRail: https://test-management.browserstack.com/projects/2148171/test-runs/TR-173/folder/12015298/39317566/801694727
Email or phone of affected tester (no customers): casluyo@gmail.com
Issue reported by: Applause Internal Team
Device used: iOs 18 / iPhone 11 pro max
App Component: Other

Action Performed:

  1. Open the Expensify app on an iOS device.
  2. Open any existing chat conversation.
  3. Type a message in the composer (message input box) but do not send it (leave it as a draft).
  4. Navigate away from that chat to a different chat or screen.
  5. Navigate back to the original chat with the draft message.

Expected Result:

When returning to a chat with a draft message, the cursor should be positioned at the end of the draft message, ready for the user to continue typing immediately.

Actual Result:

When returning to a chat with a draft message, the cursor does not appear in the composer, so the user has to manually tap the input box to continue editing.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

1.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021950475915408594604
  • Upwork Job ID: 1950475915408594604
  • Last Price Increase: 2025-08-27
Issue OwnerCurrent Issue Owner: @JmillsExpensify

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jul 24, 2025
  2. melvin-bot commented on Jul 24, 2025

    @melvin-bot

    Triggered auto assignment to @JmillsExpensify (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. Eskalifer1 commented on Jul 24, 2025

    @Eskalifer1
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    Conversation - Cursor not auto-focused in composer when returning to chat with draft

    What is the root cause of that problem?

    Currently, we do not have a logic that would allow focusing, provided that there is a draftMessage. Now, focusing is done using the canFocusInputOnScreenFocus() function, which is why focusing does not happen automatically:

    const shouldFocusInputOnScreenFocus = canFocusInputOnScreenFocus();

    return shouldFocusInputOnScreenFocus && shouldShowComposeInput && !initialModalState?.isVisible && !initialModalState?.willAlertModalBecomeVisible;

    What changes do you think we should make in order to solve the problem?

    You need to add logic to focus the input if there is a draftMessage. To do this, you can do the following:

    const [isFocused, setIsFocused] = useState(() => {
    const initialModalState = getModalState();
    return shouldFocusInputOnScreenFocus && shouldShowComposeInput && !initialModalState?.isVisible && !initialModalState?.willAlertModalBecomeVisible;
    });

    Replace with (this is for the focus style):

        const [isFocused, setIsFocused] = useState(() => {
            const initialModalState = getModalState();
            const draftComment = getDraftComment(reportID);
            return (!!draftComment || shouldFocusInputOnScreenFocus) && shouldShowComposeInput && !initialModalState?.isVisible && !initialModalState?.willAlertModalBecomeVisible;
        });

    And also add the focus itself here:

    const shouldAutoFocus = shouldFocusInputOnScreenFocus && !modal?.isVisible && shouldShowComposeInput && areAllModalsHidden() && isFocused && !didHideComposerInput;

    const shouldAutoFocus = (shouldFocusInputOnScreenFocus || !!draftComment) && !modal?.isVisible && shouldShowComposeInput && areAllModalsHidden() && isFocused && !didHideComposerInput;

    Additionally, we will need to change the check here, if necessary:

    onCanceledAttachmentPicker={() => {
    if (!shouldFocusInputOnScreenFocus) {
    return;
    }
    focus();
    }}

    I also suggest redefining the shouldFocusInputOnScreenFocus change, which will also check if there is a draftMessage.

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    N/A

    What alternative solutions did you explore? (Optional)

    Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

  4. ganzz4 commented on Jul 24, 2025

    @ganzz4
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    When a user navigates back to a chat that has a draft message, the cursor is not automatically focused in the composer input field. This forces users to manually tap the input box to continue editing their draft, creating poor UX compared to the expected behavior where they should be able to immediately continue typing.

    What is the root cause of that problem?

    When users navigate back to a chat, the system doesn't check for draft messages to determine if the composer should be auto-focused:

    const unsubscribeNavigationFocus = navigation.addListener('focus', () => {
    addKeyDownPressListener(focusComposerOnKeyPress);
    // The report isn't unmounted and can be focused again after going back from another report so we should update the composerRef again
    ReportActionComposeFocusManager.composerRef.current = textInputRef.current;
    setUpComposeFocusManager();
    });

    The listener fires when navigating to the chat but doesn't recognize that draft content indicates the user wants to continue typing.

    What changes do you think we should make in order to solve the problem?

    Add draft-aware focus logic to the existing navigation focus listener in ComposerWithSuggestions.tsx. When the navigation focus event fires, check if there's a draft message and automatically focus the composer with proper cursor positioning.

    const unsubscribeNavigationFocus = navigation.addListener('focus', () => {
        addKeyDownPressListener(focusComposerOnKeyPress);
        // The report isn't unmounted and can be focused again after going back from another report so we should update the composerRef again
        ReportActionComposeFocusManager.composerRef.current = textInputRef.current;
        setUpComposeFocusManager();
        
        // Auto-focus composer if there's a draft message when navigating back to this chat
        if (draftComment && shouldShowComposeInput && areAllModalsHidden()) {
            focus();
            updateMultilineInputRange(textInputRef.current, true);
        }
    });

    const unsubscribeNavigationFocus = navigation.addListener('focus', () => {
    addKeyDownPressListener(focusComposerOnKeyPress);
    // The report isn't unmounted and can be focused again after going back from another report so we should update the composerRef again
    ReportActionComposeFocusManager.composerRef.current = textInputRef.current;
    setUpComposeFocusManager();
    });

    This ensures the composer gains focus, the cursor is positioned at the end of the draft text, and the keyboard is shown when users return to a chat with draft content.

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    N/A

    What alternative solutions did you explore? (Optional)

  5. JmillsExpensify commented on Jul 30, 2025

    @JmillsExpensify
    Contributor

    Opening this up to the community.

  6. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Jul 30, 2025
  7. melvin-bot commented on Jul 30, 2025

    @melvin-bot
  8. changed the title [-]Conversation - Cursor not auto-focused in composer when returning to chat with draft[/-] [+][$250] Conversation - Cursor not auto-focused in composer when returning to chat with draft[/+] on Jul 30, 2025
  9. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Jul 30, 2025
  10. 47 remaining items

  11. melvin-bot commented on Nov 27, 2025

    @melvin-bot

    Reviewing label has been removed, please complete the "BugZero Checklist".

  12. melvin-bot commented on Nov 27, 2025

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.2.64-5 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 2025-12-04. 🎊

    For reference, here are some details about the assignees on this issue:

    • @alitoshmatov requires payment through NewDot Manual Requests
    • @Eskalifer1 requires payment (Needs manual offer from BZ)
  13. melvin-bot commented on Nov 27, 2025

    @melvin-bot

    @youssef-lr @JmillsExpensify @alitoshmatov / @Eskalifer1 The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero 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]

  14. melvin-bot commented on Dec 4, 2025

    @melvin-bot

    Payment Summary

    Upwork Job

    BugZero Checklist (@JmillsExpensify)

    • (if NewFeature) I have created a PR for any necessary HelpDot updates, or I confirmed no updates are necessary.
    • I have verified the correct assignees and roles are listed above and updated the necessary manual offers
    • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants/1950475915408594604/hired)
    • I have verified the PR was not reverted
    • I have applied any discounts due to bugs/regressions introduced by this PR
    • I have paid out the Upwork contracts or cancelled the ones that are incorrect
    • I have verified the payment summary above is correct
  15. JmillsExpensify commented on Dec 5, 2025

    @JmillsExpensify
    Contributor

    Payment summary:

  16. JmillsExpensify commented on Dec 5, 2025

    @JmillsExpensify
    Contributor

    @Eskalifer1 it looks like you didn't apply to the Upwork job. I'll create a new one and offer?

  17. Eskalifer1 commented on Dec 5, 2025

    @Eskalifer1
    Contributor

    Perhaps, but I think that simply more time has passed and this job is no longer available. Therefore, I think you can create a new one, thank you!

  18. JmillsExpensify commented on Dec 5, 2025

    @JmillsExpensify
    Contributor

    On it! Expect an offer shortly

  19. JmillsExpensify commented on Dec 5, 2025

    @JmillsExpensify
    Contributor

    Paid the Upwork contract and regression test created. Closing this one.

  20. trjExpensify commented on Dec 10, 2025

    @trjExpensify
    Contributor

    approved $250 for @alitoshmatov

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

Metadata

Metadata

Labels

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

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions