taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit 86a9b24b5fda03979b7976adc2fcbb9f1c0f90b5
parent acef3baeb50fa240c833dfe0dfb4863b176896f6
Author: Sebastian <sebasjm@gmail.com>
Date:   Mon, 11 Dec 2023 14:18:45 -0300

warn when clipboard is not available

Diffstat:
Mpackages/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 @@ -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) {