diff options
author | Sebastian <sebasjm@gmail.com> | 2023-12-11 14:18:45 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2023-12-11 14:18:45 -0300 |
commit | 86a9b24b5fda03979b7976adc2fcbb9f1c0f90b5 (patch) | |
tree | 42ce2388c51dcfae016bb67455ad7f56a88d528e /packages/web-util/src | |
parent | acef3baeb50fa240c833dfe0dfb4863b176896f6 (diff) | |
download | wallet-core-86a9b24b5fda03979b7976adc2fcbb9f1c0f90b5.tar.xz |
warn when clipboard is not available
Diffstat (limited to 'packages/web-util/src')
-rw-r--r-- | packages/web-util/src/components/CopyButton.tsx | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/packages/web-util/src/components/CopyButton.tsx b/packages/web-util/src/components/CopyButton.tsx index 0096da365..e76447291 100644 --- a/packages/web-util/src/components/CopyButton.tsx +++ b/packages/web-util/src/components/CopyButton.tsx @@ -20,8 +20,13 @@ export function CopiedIcon(): VNode { export function CopyButton({ class: clazz, getContent }: { class: string, getContent: () => string }): VNode { const [copied, setCopied] = useState(false); function copyText(): void { - navigator.clipboard.writeText(getContent() || ""); - setCopied(true); + if (!navigator.clipboard && !window.isSecureContext) { + alert('clipboard is not available on insecure context (http)') + } + if (navigator.clipboard) { + navigator.clipboard.writeText(getContent() || ""); + setCopied(true); + } } useEffect(() => { if (copied) { |