Fix copy token button to use execCommand for reliable copying

parent 64b18028
......@@ -200,28 +200,23 @@
const copyBtn = document.querySelector('#tokenModal .copy-btn');
const originalText = copyBtn.textContent;
navigator.clipboard.writeText(tokenText.textContent).then(function() {
copyBtn.textContent = 'Copied!';
copyBtn.style.background = '#10b981';
setTimeout(function() {
copyBtn.textContent = originalText;
copyBtn.style.background = '';
}, 2000);
}, function(err) {
// Fallback for older browsers
// Use execCommand for reliable copying
const textArea = document.createElement('textarea');
textArea.value = tokenText.textContent;
textArea.value = tokenText.textContent.trim();
document.body.appendChild(textArea);
textArea.select();
try {
document.execCommand('copy');
document.body.removeChild(textArea);
copyBtn.textContent = 'Copied!';
copyBtn.style.background = '#10b981';
setTimeout(function() {
copyBtn.textContent = originalText;
copyBtn.style.background = '';
}, 2000);
});
} catch (err) {
alert('Failed to copy token. Please select and copy manually.');
}
document.body.removeChild(textArea);
}
// Close modal when clicking outside
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment