[HOLD for payment on May 18th] Allow copying only a selection of text
If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!
Expected Result:
- Some part of the chat text is selected with the mouse
- The selected text is right clicked over
- "copy to clipboard" is chosen
- Only the selected text is copied to the clipboard
Actual Result:
- Some part of the chat text is selected with the mouse
- The selected text is right clicked over
- "copy to clipboard" is chosen
- The entire chat message is copied to the clipboard, not just the selected text
Action Performed:
See above
Workaround:
User can use CNTRL/CMD + C to copy the selection.
Platform:
This occurs on any platform where there is a mouse and it is possible to select part of the text:
Web Desktop App
Version Number: v1.0.22-1
Notes/Photos/Videos:

Upwork job posting: https://www.upwork.com/jobs/~019da55f1152a0e716 View all open jobs on Upwork
Triggered auto assignment to @Jag96 (Exported), see https://stackoverflow.com/c/expensify/questions/7972 for more details.
Proposal:
in /Users/syva80/Expensify.cash/src/components/PressableWithSecondaryInteraction/index.js
we get selection when the event is triggered. window.getSelection().toString();
use this as the second arg for onSecondaryInteraction
36: executeSecondaryInteractionOnContextMenu(e) {
+ const selection = window.getSelection().toString();
e.preventDefault();
- this.props.onSecondaryInteraction(e);
+ this.props.onSecondaryInteraction(e, selection);
}
/Users/syva80/Expensify.cash/src/pages/home/report/ReportActionItem.js we assign this.selection = selection, and then send it how prop in ReportActionContextMenu
94: showPopover(event, selection) {
const nativeEvent = event.nativeEvent || {};
this.capturePressLocation(nativeEvent);
+ this.selection = selection;
this.setState({isPopoverVisible: true});
}
158: <ReportActionContextMenu
isVisible
+ selection={this.selection}
reportID={this.props.reportID}
reportAction={this.props.action}
/>
/Users/syva80/Expensify.cash/src/pages/home/report/ReportActionContextMenu.js
we assign the const text the value props.selection or string value (if selection is undefined)
57: const text = props.selection || lodashGet(message, 'text', '');
it's work on web and desktop.
@Viacheslav80 your proposal looks good, I've invited you to accept the job in Upwork and then you can submit a PR.
@puneetlath I would like to mention one point here. Shouldn't we keep the text selected when context menu is opened so that user can know the difference?
Yes, that's a good point. We should.
Does that not happen with this change? If so, we can open a new issue to do so since this was already completed.
@puneetlath No it's not happening at the moment. I found the following issues. https://expensify.slack.com/archives/C01GTK53T8Q/p1620839026121600
Paid.