diff --git a/src/front-end/templates/toc.js.hbs b/src/front-end/templates/toc.js.hbs index 377fc4a0b2..ffaa5d589c 100644 --- a/src/front-end/templates/toc.js.hbs +++ b/src/front-end/templates/toc.js.hbs @@ -10,7 +10,7 @@ class MDBookSidebarScrollbox extends HTMLElement { connectedCallback() { this.innerHTML = '{{#toc}}{{/toc}}'; // Set the current, active page, and reveal it if it's hidden - let current_page = document.location.href.toString().split("#")[0]; + let current_page = document.location.href.toString().split("#")[0].split("?")[0]; if (current_page.endsWith("/")) { current_page += "index.html"; } diff --git a/tests/gui/sidebar-active.goml b/tests/gui/sidebar-active.goml new file mode 100644 index 0000000000..a029b2d219 --- /dev/null +++ b/tests/gui/sidebar-active.goml @@ -0,0 +1,17 @@ +// This GUI test checks the active page sidebar highlight. + +go-to: |DOC_PATH| + "index.html" + +assert-text: ("mdbook-sidebar-scrollbox a.active", "Prefix Chapter") + +go-to: |DOC_PATH| + "individual/index.html" + +assert-text: ("mdbook-sidebar-scrollbox a.active", "3. Markdown Individual tags") + +go-to: |DOC_PATH| + "index.html?highlight=test" + +assert-text: ("mdbook-sidebar-scrollbox a.active", "Prefix Chapter") + +go-to: |DOC_PATH| + "individual/index.html?highlight=test" + +assert-text: ("mdbook-sidebar-scrollbox a.active", "3. Markdown Individual tags")