fix(share): only copy to clipboard if available and secure

This commit is contained in:
Kendall Garner
2026-02-19 19:55:10 -08:00
parent ab9e02adfc
commit 0741351318
2 changed files with 16 additions and 5 deletions
@@ -74,13 +74,22 @@ export const ShareItemContextModal = ({
if (!serverUrl) throw new Error('Server URL not found');
const shareUrl = `${serverUrl}/share/${_data.id}`;
navigator.clipboard.writeText(shareUrl);
const canUseClipboard = navigator.clipboard && window.isSecureContext;
if (canUseClipboard) {
navigator.clipboard.writeText(shareUrl);
}
toast.success({
autoClose: 5000,
autoClose: canUseClipboard ? 5000 : 15000,
id: 'share-item-toast',
message: t('form.shareItem.success', {
postProcess: 'sentenceCase',
}),
message: t(
canUseClipboard
? 'form.shareItem.success'
: 'form.shareItem.successMustClick',
{
postProcess: 'sentenceCase',
},
),
onClick: (a) => {
if (!(a.target instanceof HTMLElement)) return;