App icon indicating copy to clipboard operation
App copied to clipboard

[HOLD for payment on May 18th] Allow copying only a selection of text

Open puneetlath opened this issue 5 years ago • 8 comments

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:

  1. Some part of the chat text is selected with the mouse
  2. The selected text is right clicked over
  3. "copy to clipboard" is chosen
  4. Only the selected text is copied to the clipboard

Actual Result:

  1. Some part of the chat text is selected with the mouse
  2. The selected text is right clicked over
  3. "copy to clipboard" is chosen
  4. 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: image

Upwork job posting: https://www.upwork.com/jobs/~019da55f1152a0e716 View all open jobs on Upwork

puneetlath avatar May 03 '21 02:05 puneetlath

Triggered auto assignment to @Jag96 (Exported), see https://stackoverflow.com/c/expensify/questions/7972 for more details.

MelvinBot avatar May 03 '21 02:05 MelvinBot

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 avatar May 07 '21 15:05 Viacheslav80

@Viacheslav80 your proposal looks good, I've invited you to accept the job in Upwork and then you can submit a PR.

Jag96 avatar May 07 '21 18:05 Jag96

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

parasharrajat avatar May 12 '21 13:05 parasharrajat

Yes, that's a good point. We should.

puneetlath avatar May 12 '21 17:05 puneetlath

Does that not happen with this change? If so, we can open a new issue to do so since this was already completed.

puneetlath avatar May 12 '21 17:05 puneetlath

@puneetlath No it's not happening at the moment. I found the following issues. https://expensify.slack.com/archives/C01GTK53T8Q/p1620839026121600

parasharrajat avatar May 12 '21 18:05 parasharrajat

Paid.

puneetlath avatar May 18 '21 16:05 puneetlath