Fix clipboard copy on HTTP — use execCommand fallback

navigator.clipboard requires HTTPS (secure context). Fall back to
textarea + execCommand('copy') for the View in CARD button.
This commit is contained in:
Jordan Ramos
2026-06-09 12:35:24 -06:00
parent f3319ee1f5
commit f8b420f4e4
2 changed files with 21 additions and 2 deletions

View File

@@ -155,7 +155,16 @@ export default function CardActionModal({ isOpen, onClose, item, initialAction,
{item?.host_id && (
<button
onClick={() => {
navigator.clipboard.writeText(String(item.host_id));
try {
const ta = document.createElement('textarea');
ta.value = String(item.host_id);
ta.style.position = 'fixed';
ta.style.opacity = '0';
document.body.appendChild(ta);
ta.select();
document.execCommand('copy');
document.body.removeChild(ta);
} catch (_) { /* best effort */ }
window.open('https://card.charter.com/ipn-search', '_blank');
}}
title={`Copy Host ID ${item.host_id} and open CARD`}