Skip to content

Commit 2229d71

Browse files
committed
Improve clipboard handling and update mailto link dependencies in AlertModal
1 parent 9b315b9 commit 2229d71

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

src/components/interface/AlertModal.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,17 @@ export function AlertModal() {
3636
const subject = encodeURIComponent(`Storage Connection Issue (${studyId})`);
3737
const body = encodeURIComponent(`I encountered a storage connection issue while taking a study.\n\n Warning message:\n${alertModal.message}\n\nDiagnostics information:\n${diagnosticsMessage}`);
3838
return `mailto:${studyConfig.uiConfig.contactEmail}?subject=${subject}&body=${body}`;
39-
}, [diagnosticsMessage, studyConfig.uiConfig.contactEmail, studyId]);
39+
}, [alertModal.message, diagnosticsMessage, studyConfig.uiConfig.contactEmail, studyId]);
4040

4141
const handleCopyMessage = useCallback(async () => {
42-
await navigator.clipboard.writeText(diagnosticsMessage);
43-
setCopied(true);
44-
setTimeout(() => setCopied(false), 1000);
42+
try {
43+
if (!window.isSecureContext || !navigator.clipboard?.writeText) return;
44+
await navigator.clipboard.writeText(diagnosticsMessage);
45+
setCopied(true);
46+
setTimeout(() => setCopied(false), 1000);
47+
} catch {
48+
// Fail silently when clipboard access is unavailable or denied.
49+
}
4550
}, [diagnosticsMessage]);
4651

4752
return (

0 commit comments

Comments
 (0)