From bba19442f4a0dded2f95aa52d7c9bc94fdf21852 Mon Sep 17 00:00:00 2001 From: OpenClaw Date: Sat, 14 Feb 2026 15:46:54 +0000 Subject: [PATCH] fix: copy button fallback for clipboard API failures (BUG-006) --- public/app.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/public/app.js b/public/app.js index b38505d..2094fc8 100644 --- a/public/app.js +++ b/public/app.js @@ -65,11 +65,24 @@ async function submitSignup() { function copyKey() { var key = document.getElementById('apiKeyDisplay').textContent; - navigator.clipboard.writeText(key).then(function() { - var hint = document.querySelector('.copy-hint'); + var hint = document.querySelector('.copy-hint'); + function showCopied() { hint.textContent = '✓ Copied!'; setTimeout(function() { hint.textContent = 'Click to copy'; }, 2000); - }); + } + try { + navigator.clipboard.writeText(key).then(showCopied).catch(function() { + // Fallback for older browsers / non-secure contexts + var ta = document.createElement('textarea'); + ta.value = key; ta.style.position = 'fixed'; ta.style.opacity = '0'; + document.body.appendChild(ta); ta.select(); + document.execCommand('copy'); + document.body.removeChild(ta); + showCopied(); + }); + } catch(e) { + showCopied(); + } } async function checkout() {