From 49e57b4454b97d3aaa59ead1b1913b3b569ef4bc Mon Sep 17 00:00:00 2001 From: Simon Laux Date: Fri, 14 Apr 2023 01:25:53 +0200 Subject: [PATCH] always show copy link when right clicking a link in a message (#3187) closes #3184 --- CHANGELOG.md | 1 + src/renderer/components/message/Message.tsx | 16 ++++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f687f79cc4..8aa9e8ea69 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - fix show error messages when starting a video chat - don't show video chat in attachment menu when the feature is turned off - fix "Always Load Remote Images" should be hidden for contact requests #3180 +- always show copy link when right clicking a link in a message #3184 diff --git a/src/renderer/components/message/Message.tsx b/src/renderer/components/message/Message.tsx index 7c1dfda2c2..7222578aca 100644 --- a/src/renderer/components/message/Message.tsx +++ b/src/renderer/components/message/Message.tsx @@ -145,7 +145,9 @@ function buildContextMenu( throw new Error('cannot show context menu for undefined message') } - const isLink = clickTarget && !clickTarget.getAttribute('x-not-a-link') + const isLink = Boolean( + clickTarget && !clickTarget.getAttribute('x-not-a-link') + ) const email = clickTarget?.getAttribute('x-target-email') const link: string = clickTarget?.getAttribute('x-target-url') || clickTarget?.href || '' @@ -174,11 +176,6 @@ function buildContextMenu( runtime.writeClipboardText(selectedText as string) }, } - } else if (link !== '' && isLink) { - copy_item = { - label: tx('menu_copy_link_to_clipboard'), - action: () => runtime.writeClipboardText(link), - } } else if (email) { copy_item = { label: tx('menu_copy_email_to_clipboard'), @@ -205,6 +202,13 @@ function buildContextMenu( label: tx('reply_privately'), action: privateReply.bind(null, message), }, + // copy link + link !== '' && + isLink && { + label: tx('menu_copy_link_to_clipboard'), + action: () => runtime.writeClipboardText(link), + }, + // copy item (selection or all text) text !== '' && copy_item, // Copy image showCopyImage && {