Skip to content

Commit

Permalink
Ensure sidebar toggle patch is loaded correctly (#7349)
Browse files Browse the repository at this point in the history
* Ensure sidebar toggle patch is loaded correctly

* Fix toggle.js

* Add listener on cloned button

---------

Co-authored-by: Simon Høxbro Hansen <simon.hansen@me.com>
  • Loading branch information
philippjfr and hoxbro authored Oct 2, 2024
1 parent 07481b9 commit 3e06a45
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
12 changes: 4 additions & 8 deletions doc/_static/toggle.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
export function documentReady(callback) {
if (document.readyState != "loading") callback();
else document.addEventListener("DOMContentLoaded", callback);
}

function clone(node) {
var new_element = node.cloneNode(true);
node.parentNode.replaceChild(new_element, node);
return new_element
}

export function documentReady(callback) {
function documentReady(callback) {
if (document.readyState != "loading") callback();
else document.addEventListener("DOMContentLoaded", callback);
}
Expand Down Expand Up @@ -44,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;
Expand Down
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def get_requirements():
html_js_files = [
(None, {'body': '{"shimMode": true}', 'type': 'esms-options'}),
f'https://cdn.holoviz.org/panel/{js_version}/dist/bundled/reactiveesm/es-module-shims@^1.10.0/dist/es-module-shims.min.js',
'_static/toggle.js'
'toggle.js'
]

nbsite_pyodide_conf = {
Expand Down

0 comments on commit 3e06a45

Please sign in to comment.