From f58ce89099df8ff5fb6c1b55290b66af814e576e Mon Sep 17 00:00:00 2001 From: lawrence3699 Date: Mon, 27 Apr 2026 22:00:35 +1000 Subject: [PATCH] Fix keyboard access for sidebar toggle --- crates/mdbook-html/front-end/css/chrome.css | 3 +++ crates/mdbook-html/front-end/js/book.js | 2 ++ crates/mdbook-html/front-end/templates/index.hbs | 5 ++++- tests/gui/sidebar.goml | 11 +++++++++++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/crates/mdbook-html/front-end/css/chrome.css b/crates/mdbook-html/front-end/css/chrome.css index bab38894f4..84eb67ba80 100644 --- a/crates/mdbook-html/front-end/css/chrome.css +++ b/crates/mdbook-html/front-end/css/chrome.css @@ -94,6 +94,9 @@ html.sidebar-visible #mdbook-menu-bar { html:not(.js) .left-buttons button { display: none; } +html.js #mdbook-sidebar-toggle-nojs { + display: none; +} .menu-title { display: inline-block; diff --git a/crates/mdbook-html/front-end/js/book.js b/crates/mdbook-html/front-end/js/book.js index 62d7c4cc87..ab20472c80 100644 --- a/crates/mdbook-html/front-end/js/book.js +++ b/crates/mdbook-html/front-end/js/book.js @@ -548,6 +548,8 @@ aria-label="Show hidden lines">'; // reflow after updating the display. sidebar.offsetHeight; } + sidebarCheckbox.checked = !sidebarCheckbox.checked; + sidebarCheckbox.dispatchEvent(new Event('change')); }); function showSidebar() { diff --git a/crates/mdbook-html/front-end/templates/index.hbs b/crates/mdbook-html/front-end/templates/index.hbs index b1834189f9..78a56c59e8 100644 --- a/crates/mdbook-html/front-end/templates/index.hbs +++ b/crates/mdbook-html/front-end/templates/index.hbs @@ -143,9 +143,12 @@