diff --git a/src/components/post-desktop/post-menu-desktop/post-menu-desktop.tsx b/src/components/post-desktop/post-menu-desktop/post-menu-desktop.tsx
index d916d011..1dd9724c 100644
--- a/src/components/post-desktop/post-menu-desktop/post-menu-desktop.tsx
+++ b/src/components/post-desktop/post-menu-desktop/post-menu-desktop.tsx
@@ -21,9 +21,14 @@ const CopyLinkButton = ({ cid, subplebbitAddress, linkType, onClose }: { cid?: s
const boardIdentifier = getBoardPath(subplebbitAddress, defaultSubplebbits);
return (
{
- copyShareLinkToClipboard(boardIdentifier, linkType, cid);
- onClose();
+ onClick={async () => {
+ try {
+ await copyShareLinkToClipboard(boardIdentifier, linkType, cid);
+ } catch (error) {
+ console.error('Failed to copy share link', error);
+ } finally {
+ onClose();
+ }
}}
>
{t('copy_link')}
@@ -35,9 +40,14 @@ const CopyContentIdButton = ({ cid, onClose }: { cid: string; onClose: () => voi
const { t } = useTranslation();
return (
{
- copyToClipboard(cid);
- onClose();
+ onClick={async () => {
+ try {
+ await copyToClipboard(cid);
+ } catch (error) {
+ console.error('Failed to copy content id', error);
+ } finally {
+ onClose();
+ }
}}
>
{t('copy_content_id')}
diff --git a/src/components/post-mobile/post-menu-mobile/post-menu-mobile.tsx b/src/components/post-mobile/post-menu-mobile/post-menu-mobile.tsx
index 5811f55b..bd5b9137 100644
--- a/src/components/post-mobile/post-menu-mobile/post-menu-mobile.tsx
+++ b/src/components/post-mobile/post-menu-mobile/post-menu-mobile.tsx
@@ -29,9 +29,14 @@ const CopyLinkButton = ({ cid, subplebbitAddress, linkType, onClose }: { cid?: s
const boardIdentifier = getBoardPath(subplebbitAddress, defaultSubplebbits);
return (
{
- copyShareLinkToClipboard(boardIdentifier, linkType, cid);
- onClose();
+ onClick={async () => {
+ try {
+ await copyShareLinkToClipboard(boardIdentifier, linkType, cid);
+ } catch (error) {
+ console.error('Failed to copy share link', error);
+ } finally {
+ onClose();
+ }
}}
>
{t('copy_link')}
@@ -43,9 +48,14 @@ const CopyContentIdButton = ({ cid, onClose }: { cid: string; onClose: () => voi
const { t } = useTranslation();
return (
{
- copyToClipboard(cid);
- onClose();
+ onClick={async () => {
+ try {
+ await copyToClipboard(cid);
+ } catch (error) {
+ console.error('Failed to copy content id', error);
+ } finally {
+ onClose();
+ }
}}
>
{t('copy_content_id')}