Skip to content

Commit 75e79e6

Browse files
authored
Merge pull request #1654 from session-foundation/fix-allow-copy-selected-txt
fix: allow to copy selected text on copy menu item
2 parents c37ff42 + 9e07fb2 commit 75e79e6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

ts/components/conversation/message/message-content/MessageContextMenu.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,10 @@ export const MessageContextMenu = (props: Props) => {
216216
}, [isSelectedBlocked, messageId]);
217217

218218
const copyText = useCallback(() => {
219-
MessageInteraction.copyBodyToClipboard(text);
219+
const selection = window.getSelection();
220+
const selectedText = selection?.toString().trim();
221+
// Note: we want to allow to copy through the "Copy" menu item the currently selected text, if any.
222+
MessageInteraction.copyBodyToClipboard(selectedText || text);
220223
}, [text]);
221224

222225
const onSelect = useCallback(() => {

0 commit comments

Comments
 (0)