fix: fallback to execCommand to copy logs to clipboard

This commit is contained in:
Sam Chau
2026-01-22 18:01:46 +10:30
parent 97c21b9572
commit 7bd2ee2493
2 changed files with 15 additions and 6 deletions

View File

@@ -4,11 +4,7 @@
- font is too small in some places / too squished
- rethink job polling architecture
- maybe move langauges to general tab or put info directly below it to fill
space
- adding a database requires double click??? im not running into this personally
- new quality handling
- copy button on logs page not woprking? cant recreate
# Adaptive Backoff

View File

@@ -133,8 +133,21 @@
try {
await navigator.clipboard.writeText(logText);
alertStore.add('success', 'Log entry copied to clipboard');
} catch (err) {
alertStore.add('error', 'Failed to copy to clipboard');
} catch {
// Fallback for non-secure contexts (HTTP + non-localhost)
const textArea = document.createElement('textarea');
textArea.value = logText;
textArea.style.position = 'fixed';
textArea.style.left = '-9999px';
document.body.appendChild(textArea);
textArea.select();
try {
document.execCommand('copy');
alertStore.add('success', 'Log entry copied to clipboard');
} catch {
alertStore.add('error', 'Failed to copy to clipboard');
}
document.body.removeChild(textArea);
}
}