Change:
Take any page in the Rust docs, for example . When you press the or keyboard shortcuts on your keyboard, they are supposed to either collapse or expand all items on the page, but not both (according to the instructions that you can find by clicking on your keyboard (or on the screen). Please make the + and - keyboard shortcuts idempotent, otherwise it would be redundant to have two buttons that do the same thing.
What do you think about this ?
Yeah we should do this.
I'll send a patch in the next days then.

Discussion:
break; case "+": <ins> ev.preventDefault(); expandAllDocs(); break; </ins> case "-": ev.preventDefault(); <del> toggleAllDocs(); </del> <ins> collapseAllDocs(); </ins> break; case "?":

sidebarElems.appendChild(ul); } <ins> function expandAllDocs() { const innerToggle = document.getElementById(toggleAllDocsId); removeClass(innerToggle, "will-expand"); onEachLazy(document.getElementsByClassName("rustdoc-toggle"), e => { if (!hasClass(e, "type-contents-toggle")) { e.open = true; } }); innerToggle.title = "collapse all docs"; innerToggle.children[0].innerText = "u2212"; // "u2212" is "−" minus sign } </ins> <del> function labelForToggleButton(sectionIsCollapsed) { if (sectionIsCollapsed) { // button will expand the section return "+"; } // button will collapse the section // note that this text is also set in the HTML template in ../render/mod.rs return "u2212"; // "u2212" is "−" minus sign </del> <ins> function collapseAllDocs() { const innerToggle = document.getElementById(toggleAllDocsId); addClass(innerToggle, "will-expand"); onEachLazy(document.getElementsByClassName("rustdoc-toggle"), e => { if (e.parentNode.id !== "implementations-list" || (!hasClass(e, "implementors-toggle") && !hasClass(e, "type-contents-toggle")) ) { e.open = false; } }); innerToggle.title = "expand all docs"; innerToggle.children[0].innerText = "+"; </ins> } function toggleAllDocs() {

if (!innerToggle) { return; } <del> let sectionIsCollapsed = false; </del> if (hasClass(innerToggle, "will-expand")) { <del> removeClass(innerToggle, "will-expand"); onEachLazy(document.getElementsByClassName("rustdoc-toggle"), e => { if (!hasClass(e, "type-contents-toggle")) { e.open = true; } }); innerToggle.title = "collapse all docs"; </del> <ins> expandAllDocs(); </ins> } else { <del> addClass(innerToggle, "will-expand"); onEachLazy(document.getElementsByClassName("rustdoc-toggle"), e => { if (e.parentNode.id !== "implementations-list" || (!hasClass(e, "implementors-toggle") && !hasClass(e, "type-contents-toggle")) ) { e.open = false; } }); sectionIsCollapsed = true; innerToggle.title = "expand all docs"; </del> <ins> collapseAllDocs(); </ins> } <del> innerToggle.children[0].innerText = labelForToggleButton(sectionIsCollapsed); </del> } (function() {

assert-css: ("#help-button .popover", {"display": "block"}) press-key: "Escape" assert-css: ("#help-button .popover", {"display": "none"}) <ins> // Checking doc collapse and expand. // It should be displaying a "-": assert-text: ("#toggle-all-docs", "[u2212]") press-key: "-" wait-for-text: ("#toggle-all-docs", "[+]") assert-attribute: ("#toggle-all-docs", {"class": "will-expand"}) // Pressing it again shouldn't do anything. press-key: "-" assert-text: ("#toggle-all-docs", "[+]") assert-attribute: ("#toggle-all-docs", {"class": "will-expand"}) // Expanding now. press-key: "+" wait-for-text: ("#toggle-all-docs", "[u2212]") assert-attribute: ("#toggle-all-docs", {"class": ""}) // Pressing it again shouldn't do anything. press-key: "+" assert-text: ("#toggle-all-docs", "[u2212]") assert-attribute: ("#toggle-all-docs", {"class": ""}) </ins>