Skip to content

iOS - Keyboard closes after pasting text into the composer #86578

Closed

Description

@lanitochka17

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.50-2
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/13176681/test-cases/41236971
Email or phone of affected tester (no customers): fischer9966+053122@gmail.com
Issue reported by: Applause Internal Team
Bug source: Regression TC Execution
Device used: iPhone 17 Pro / 26.3.1. iPad 9th gen / 26.3.1
App Component: Chat Report View

Action Performed:

  1. Login with any account to Expensify app on iPhone or iPad
  2. Go to any chat
  3. Tap to composer field to open keyboard
  4. Copy any text and paste it into composer

Expected Result:

Keyboard remain open after pasting text into the composer field

Actual Result:

Keyboard closes after pasting text into the composer field

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7115160_1774634270566.iOS-keyboard-close-after-paste.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @chrispader

Activity

  1. added
    DeployBlockerCashThis issue or pull request should block deployment
    BugSomething is broken. Auto assigns a BugZero manager.
    on Mar 27, 2026
  2. melvin-bot commented on Mar 27, 2026

    @melvin-bot

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

  3. github-actions commented on Mar 27, 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.
  4. melvin-bot commented on Mar 27, 2026

    @melvin-bot

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

  5. OSBotify commented on Mar 27, 2026

    @OSBotify
    Contributor

    Investigation Summary

    Classification: Frontend bug
    Causing PR: #84423 - "Multi file upload support (v2)" by @chrispader (High confidence)
    Related Issues: None

    Recommendation: REVERT

    PR #84423 modified the React Native patch for onPaste to support multiple files. The iOS implementation has a bug where pasting plain text calls [super paste:sender] to keep the keyboard open, but pasting text that contains any rich formatting (HTML, RTF, etc.) skips the [super paste:sender] call, causing iOS to dismiss the keyboard.

    When you copy text on iOS and paste it, the clipboard often contains BOTH plain text AND rich text/HTML representations. The paste handler checks for file URL representations and takes the "slow path" for any non-plain-text clipboard items, which results in the keyboard being dismissed.

    Labels: Keeping DeployBlockerCash (frontend bug blocking App deploy). No label changes needed.

    Detailed Analysis

    Evidence

    • Issue reproduces only on staging (iOS native app)
    • Issue appeared in version 9.3.50-2
    • PR Multi file upload support (v2) #84423 is in the deploy checklist and modifies paste handling
    • PR updates the React Native patch react-native+0.83.1+011+Add-onPaste-to-TextInput.patch
    • PR also modifies src/components/Composer/implementation/index.native.tsx

    Verification

    The React Native patch in PR #84423 modifies /node_modules/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.mm:

    // Fast path for plain text - also call super to insert the text
    if (clipboard.hasStrings && clipboard.string != nil &&
        ![RCTPasteHandlerUtil containsFileURLRepresentation:clipboard]) {
      NSDictionary<NSString *, NSString *> *stringItem = @{@"type": @"text/plain", @"data": clipboard.string};
      [_textInputDelegateAdapter didPaste:@[stringItem]];
      [super paste:sender];  // ← Keyboard stays open
      return;
    }
    
    // Process non-text items using the utility
    NSArray<NSDictionary<NSString *, NSString *> *> *items =
        [RCTPasteHandlerUtil itemInfosFromPasteboard:clipboard];
    
    if (items.count == 0) {
      [super paste:sender];
      return;
    }
    
    [_textInputDelegateAdapter didPaste:items];  // ← Missing [super paste:sender] causes keyboard to close

    Root Cause

    When pasting text that contains rich formatting (which is common when copying from any app), iOS takes the second code path that processes "non-text items". This path calls [_textInputDelegateAdapter didPaste:items] but does NOT call [super paste:sender], which causes iOS to dismiss the keyboard because the system thinks the paste operation is complete without actually modifying the text input.

    The fix needs to either:

    1. Always call [super paste:sender] when pasting text (even if rich formatted)
    2. Or prevent the keyboard from dismissing after the paste handler completes
  6. MelvinBot commented on Mar 27, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    PR #84423 (Multi file upload support v2) modified the React Native onPaste iOS native patch to fire the didPaste: callback for all paste events, including plain text. Previously, pasting plain text only called [super paste:sender] to insert the text and did not fire the JS onPaste event.

    Now when plain text is pasted on iOS:

    1. The native patch fires didPaste: with a text/plain item → triggers the JS onPaste event
    2. The Composer's pasteFile handler in index.native.tsx:91-126 filters out text/plain items but still calls onPasteFile([]) with an empty array
    3. In ComposerWithSuggestions.tsx:965-968, the onPasteFile wrapper unconditionally calls textInputRef.current?.blur(), which dismisses the keyboard — even when the files array is empty

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

    In src/components/Composer/implementation/index.native.tsx, skip calling onPasteFile when the resulting files array is empty. This restores the pre-PR-#84423 behavior where plain text pastes never reach onPasteFile:

    // In the pasteFile callback, after Promise.allSettled:
    if (files.length > 0) {
        onPasteFile(files);
    }
    

    This is the most minimal and correct fix — it keeps the native patch sending all paste events (which may be useful for future features) while preventing the empty-array path from triggering the blur.

    What alternative solutions did you explore?

    1. Guard the blur() in ComposerWithSuggestions.tsx: Only call blur() when files.length > 0. This would also work but is a less clean fix since it's better to not propagate an empty event at all.

    2. Modify the native iOS patch to not fire didPaste: for text-only pastes. This would work but removes a potentially useful signal (knowing when text was pasted) and the native patch already handles this correctly — the issue is in the JS layer.


    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.

  7. parasharrajat commented on Mar 28, 2026

    @parasharrajat
    Member
  8. chrispader commented on Mar 30, 2026

    @chrispader
    Contributor

    Looking into this straight away.

  9. melvin-bot commented on Mar 30, 2026

    @melvin-bot

    ⚠️ Looks like this issue was linked to a Deploy Blocker here

    If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.

    If a regression has occurred and you are the assigned CM follow the instructions here.

    If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future.

  10. dangrous commented on Mar 30, 2026

    @dangrous
    Contributor

    PR is being reverted, I believe - #86652

  11. chrispader commented on Mar 30, 2026

    @chrispader
    Contributor
  12. jasperhuangg commented on Mar 31, 2026

    @jasperhuangg
    Contributor

    @dangrous requested retest here

  13. m-natarajan commented on Mar 31, 2026

    @m-natarajan

    Not repro, iPhone13/26.3.1, v9.3.50-4 PR:86652 Ad-Hoc

    ScreenRecording_03-30-2026.22-23-00_1.MP4
  14. m-natarajan commented on Mar 31, 2026

    @m-natarajan

    Not reproducible on iPhone 13/iOS 26.3 v9.3.50-7 PR:86730 Ad-Hoc

    ScreenRecording_03-31-2026.16-43-12_1.MP4
  15. dangrous commented on Mar 31, 2026

    @dangrous
    Contributor

    Nice, I think we can close this.

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.EngineeringHourlyKSv2ReviewingHas a PR in review

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions