From 6f1fcafc2c795cd4a2a48dbc42a137d58048fe3b Mon Sep 17 00:00:00 2001 From: plebeius Date: Sat, 6 Dec 2025 16:46:29 +0100 Subject: [PATCH] fix(post-menu): await clipboard copy before closing menu --- .../post-menu-desktop/post-menu-desktop.tsx | 22 ++++++++++++++----- .../post-menu-mobile/post-menu-mobile.tsx | 22 ++++++++++++++----- 2 files changed, 32 insertions(+), 12 deletions(-) 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')}