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:
@@ -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}`);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user