Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/CopyToClipboard/copyText.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export function copyText(text: string) {
if (typeof navigator !== 'undefined' && navigator.clipboard?.writeText) {
try {
return navigator.clipboard.writeText(text);
navigator.clipboard.writeText(text);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How this solves the problem?

Copy link
Contributor

@amje amje Sep 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

writeText returns a Promise, so if it fails normally (security issue) we'll never get into the catch block and run fallback

Copy link
Contributor

@amje amje Sep 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this should we async/await function to work correctly indeed

} catch (error) {
return typeof document === 'undefined' ? Promise.reject(error) : copyTextFallback(text);
}
Expand Down