fix: clipboard copy fallback for non-HTTPS contexts

navigator.clipboard.writeText is undefined on HTTP. Added textarea
fallback using execCommand('copy').
This commit is contained in:
2026-03-22 20:24:17 +03:00
parent 7cbba9d3fd
commit c26b71db85
+13 -1
View File
@@ -171,7 +171,19 @@
function copyChatId(e: Event, chatId: string) {
e.stopPropagation();
navigator.clipboard.writeText(chatId);
if (navigator.clipboard?.writeText) {
navigator.clipboard.writeText(chatId);
} else {
// Fallback for non-HTTPS contexts
const ta = document.createElement('textarea');
ta.value = chatId;
ta.style.position = 'fixed';
ta.style.opacity = '0';
document.body.appendChild(ta);
ta.select();
document.execCommand('copy');
document.body.removeChild(ta);
}
snackInfo(`${t('snack.copied')}: ${chatId}`);
}