Skip to content

Fix multi-message copy on desktop web chat rows. - #102143

Merged
Julesssss merged 2 commits into
Expensify:mainfrom
neerajbachani:fix/37447-multi-message-copy
Oct 13, 2026
Merged

Julesssss merged 2 commits into
Expensify:mainfrom
neerajbachani:fix/37447-multi-message-copy

Conversation

@neerajbachani

@neerajbachani neerajbachani commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

On desktop web Chrome, chat rows use role="button" (added in #78527 for Appium tab navigation). That activates BaseGenericPressable's button behavior: user-select: none on the row wrapper and a data-selection-scrapper-hidden-element marker. For multi-message selections, SelectionScraper strips every marked row from the cloned selection, getClipboardText returns empty text, and setHtml bails before writing to the clipboard. Paste then shows stale clipboard content.

Safari was already fixed in #90541 by skipping the button role there. This PR completes the fix for Chrome by:

  1. Adding a shouldAllowTextSelection prop to GenericPressable so callers can opt out of selection suppression while keeping role="button" for accessibility/tab stops.
  2. Passing shouldAllowTextSelection={hasHoverSupport()} on chat rows in ReportActionItem (desktop web only).
  3. Normalizing <button> to <div> in SelectionScraper.replaceNodes so the HTML clipboard flavor stays block-level for composer paste.

Native and mobile behavior is unchanged because hasHoverSupport() is false on those platforms.

Fixed Issues

$ #37447
PROPOSAL: #37447 (comment)

Tests

  1. Open the app in macOS Chrome.
  2. Open any chat with several text messages.
  3. Click and drag to select text across multiple messages. Start the drag on the message text itself.
  4. Press Cmd+C to copy.
  5. Paste into the composer.
  6. Verify the pasted text includes all selected messages in the correct order with line breaks between them.
  7. Repeat steps 3-6 with a single message selection and verify copy/paste still works.
  8. Tab through chat rows and verify rows remain focusable (button role preserved).
  9. Open the app in macOS Safari.
  10. Repeat steps 3-6 for multi-message and single-message copy/paste.
  11. Verify Safari behavior is unchanged and still works.
  • Verify that no errors appear in the JS console

Offline tests

Same as Tests.

QA Steps

Same as Tests.

Note: Start the selection by clicking and dragging on the message text itself. Clicking the empty space next to the message does not start a selection. This is existing Chrome behavior and is expected.

  • Verify that no errors appear in the JS console

PR Author Checklist

  • 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

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

Chrome

Screen.Recording.2026-09-14.at.9.54.41.PM.mov

Safari

Screen.Recording.2026-09-14.at.9.56.23.PM.mov

Allow text selection on button-role report action rows via shouldAllowTextSelection,
and normalize button tags in SelectionScraper so pasted messages keep line breaks.
@codecov

codecov Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
...cPressable/implementation/BaseGenericPressable.tsx 81.45% <100.00%> (+0.30%) ⬆️
src/libs/SelectionScraper/index.ts 83.07% <100.00%> (+0.53%) ⬆️
src/pages/inbox/report/ReportActionItem.tsx 91.35% <0.00%> (+0.44%) ⬆️
... and 597 files with indirect coverage changes

The new file imported a .ts path and used DOM casts that fail typecheck and ESLint.
@neerajbachani
neerajbachani marked this pull request as ready for review September 28, 2026 21:40
@neerajbachani
neerajbachani requested review from a team as code owners September 28, 2026 21:40
@melvin-bot
melvin-bot Bot requested review from dylanexpensify and eh2077 and removed request for a team September 28, 2026 21:40
@melvin-bot

melvin-bot Bot commented Sep 28, 2026

Copy link
Copy Markdown

@eh2077 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 removed the request for review from a team September 28, 2026 21:40

@dylanexpensify dylanexpensify 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.

Looks good from a product perspective 👍

@eh2077

eh2077 commented Sep 29, 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

Android: HybridApp

NA

Android: mWeb Chrome

NA

iOS: HybridApp

NA

iOS: mWeb Safari

NA

MacOS: Chrome / Safari
Screen.Recording.2026-10-12.at.9.12.21.PM.mov

@eh2077

eh2077 commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Bug: text selection needs to click at the right start of text, or it doesn't work

Screen.Recording.2026-10-01.at.10.00.00.PM.mov

@eh2077

eh2077 commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Bug: selection doesn't work when select short message and long message

  1. reload page
  2. click and drag to select short and long message together
  3. selection doesn't work
Screen.Recording.2026-10-01.at.10.04.00.PM.mov

@neerajbachani

Copy link
Copy Markdown
Contributor Author

Thanks @eh2077, I checked both of these on staging Chrome and they already happen there.

  1. You have to start the drag right on the text. Clicking the empty space next to the message does not start a selection.
Screen.Recording.2026-10-03.at.8.51.41.PM.mov
  1. Selecting a short message and a long message together is flaky. Sometimes the selection breaks partway through the drag, and it is easier to hit after a reload.
Screen.Recording.2026-10-03.at.8.50.50.PM.online-video-cutter.com.mp4

So this PR did not introduce either bug. It only fixes the empty clipboard on multi-message copy. Happy to look at these as a follow-up if we want to handle them separately.

@neerajbachani

Copy link
Copy Markdown
Contributor Author

@eh2077 Bump ^

@eh2077

eh2077 commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

@neerajbachani

You have to start the drag right on the text. Clicking the empty space next to the message does not start a selection.

I think it's fine then. Can you add a note to QA steps please?

@neerajbachani

Copy link
Copy Markdown
Contributor Author

Added a note to the QA steps.

@eh2077 all yours.

@eh2077

eh2077 commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Selecting a short message and a long message together is flaky. Sometimes the selection breaks partway through the drag, and it is easier to hit after a reload.

Hmm, I think we should fix it for better UX. If it's a tricky issue requires going down a rabbit hole, then we can consider fix it as a follow-up.

@neerajbachani

Copy link
Copy Markdown
Contributor Author

Thanks @eh2077. I think the best move is to open a follow up and fix both Chrome issues there, for a better UX.

I checked Safari and neither of these happens there. I would rather keep this PR to the copy fix and handle both Chrome selection issues together in the follow up.

  1. The drag has to start on the message text. Clicking the empty space next to it does not start a selection.
  2. Selecting a short message and a long message together is flaky. The selection can break partway through the drag, and it is easier to hit after a reload.

These need a separate pass because the cause is not fully proven yet, and the likely fix sits in shared list code. My best guess is that FlashList reorders the message rows in the DOM about a second after layout settles. A long message often finishes measuring after a reload, and if that reorder happens mid-drag the selection breaks partway through. It is flaky, so we would need extra logging to confirm, and the fix would be in the FlashList ordering patch that also keeps tab order correct. I would rather not mix that into this copy fix.

I'm good to open a seperate follow up pr

cc: @Julesssss

@Julesssss

Copy link
Copy Markdown
Contributor

I think the best move is to open a follow up and fix both Chrome issues there, for a better UX.

Yeah happy for that to be fixed as a follow up in seperate PR

@eh2077 eh2077 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.

@neerajbachani please update checklist to green CI checks, thx!

@neerajbachani

Copy link
Copy Markdown
Contributor Author

@neerajbachani please update checklist to green CI checks, thx!

@eh2077 Fixed. All yours!!

@melvin-bot
melvin-bot Bot requested a review from Julesssss October 13, 2026 14:22
@Julesssss
Julesssss merged commit f849f0e into Expensify:main Oct 13, 2026
40 of 44 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

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

@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.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/Julesssss in version: 9.5.9-0 🚀

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

@MelvinBot

Copy link
Copy Markdown
Contributor

No help site update needed. This PR is a bug fix that makes copying and pasting text across multiple chat messages work on desktop Chrome, which is what users already expect, so no article sentence is now incorrect.


view run

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/cristipaval in version: 9.5.9-4 🚀

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants