[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-wallet-core] 01/02: warn when clipboard is not available
From: |
gnunet |
Subject: |
[taler-wallet-core] 01/02: warn when clipboard is not available |
Date: |
Mon, 11 Dec 2023 19:22:13 +0100 |
This is an automated email from the git hooks/post-receive script.
sebasjm pushed a commit to branch master
in repository wallet-core.
commit 86a9b24b5fda03979b7976adc2fcbb9f1c0f90b5
Author: Sebastian <sebasjm@gmail.com>
AuthorDate: Mon Dec 11 14:18:45 2023 -0300
warn when clipboard is not available
---
packages/web-util/src/components/CopyButton.tsx | 9 +++++++--
1 file 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) {
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.