From 8e21b5d73f3e28c92f6ea31bfe67b20f68abce45 Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Tue, 1 Oct 2024 11:12:24 +0200 Subject: [PATCH] Add listener on cloned button --- doc/_static/toggle.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/_static/toggle.js b/doc/_static/toggle.js index 6b449f6255..d49442cf13 100644 --- a/doc/_static/toggle.js +++ b/doc/_static/toggle.js @@ -1,6 +1,7 @@ function clone(node) { var new_element = node.cloneNode(true); node.parentNode.replaceChild(new_element, node); + return new_element } function documentReady(callback) { @@ -39,8 +40,8 @@ function setupMobileSidebarKeyboardHandlers() { if (!clickTransmitter) { return; } - clone(clickTransmitter) - clickTransmitter.addEventListener("click", (event) => { + const cloned = clone(clickTransmitter) + cloned.addEventListener("click", (event) => { event.preventDefault(); event.stopPropagation(); toggle.checked = !toggle.checked;