From c26b71db8534642cfe7af190e90c0ad066f9f4e0 Mon Sep 17 00:00:00 2001 From: "alexei.dolgolyov" Date: Sun, 22 Mar 2026 20:24:17 +0300 Subject: [PATCH] fix: clipboard copy fallback for non-HTTPS contexts navigator.clipboard.writeText is undefined on HTTP. Added textarea fallback using execCommand('copy'). --- frontend/src/routes/bots/TelegramBotTab.svelte | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/frontend/src/routes/bots/TelegramBotTab.svelte b/frontend/src/routes/bots/TelegramBotTab.svelte index f0594ca..11b458b 100644 --- a/frontend/src/routes/bots/TelegramBotTab.svelte +++ b/frontend/src/routes/bots/TelegramBotTab.svelte @@ -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}`); }