diff --git a/js/clipboard.js b/js/clipboard.js index 6827590a..78acd923 100644 --- a/js/clipboard.js +++ b/js/clipboard.js @@ -11,7 +11,7 @@ import "./clipboard.css"; * @param {Element} trigger * @param {Element} clipboard */ -export function setupClipboard(trigger, clipboard, canvas) { +export function setupClipboard(trigger, clipboard, parent) { const arrowElement = clipboard.querySelector(".arrow"); function updatePosition() { computePosition(trigger, clipboard, { @@ -53,6 +53,7 @@ export function setupClipboard(trigger, clipboard, canvas) { trigger.classList.toggle("active"); updatePosition(); e.preventDefault(); + e.stopPropagation(); }); // If the clipboard is clicked this should not be passed to the desktop @@ -60,7 +61,7 @@ export function setupClipboard(trigger, clipboard, canvas) { e.stopPropagation(); }); // Close the popup if we click outside it - canvas.addEventListener("click", () => { + parent.addEventListener("click", () => { if (trigger.classList.contains("active")) { clipboard.classList.toggle("hidden"); trigger.classList.toggle("active"); diff --git a/js/index.js b/js/index.js index e661ba60..c11a3e34 100644 --- a/js/index.js +++ b/js/index.js @@ -85,7 +85,7 @@ function connect() { setupClipboard( document.getElementById("clipboard-button"), document.getElementById("clipboard-container"), - document.getElementsByTagName("canvas")[0], + document.body, ); }