Skip to content

Commit e466eb2

Browse files
authored
Rollup merge of #107042 - notriddle:notriddle/rustdoc-js-question, r=GuillaumeGomez
rustdoc: fix corner cases with "?" JS keyboard command
2 parents ff83043 + bb5fb53 commit e466eb2

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/librustdoc/html/static/js/main.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,8 @@ function loadCss(cssUrl) {
390390
}
391391

392392
if (document.activeElement.tagName === "INPUT" &&
393-
document.activeElement.type !== "checkbox") {
393+
document.activeElement.type !== "checkbox" &&
394+
document.activeElement.type !== "radio") {
394395
switch (getVirtualKey(ev)) {
395396
case "Escape":
396397
handleEscape(ev);
@@ -1082,6 +1083,9 @@ function loadCss(cssUrl) {
10821083
* Show the help popup menu.
10831084
*/
10841085
function showHelp() {
1086+
// Prevent `blur` events from being dispatched as a result of closing
1087+
// other modals.
1088+
getHelpButton().querySelector("a").focus();
10851089
const menu = getHelpMenu(true);
10861090
if (menu.style.display === "none") {
10871091
window.hideAllModals();

tests/rustdoc-gui/settings.goml

+19
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,25 @@ press-key: "?"
203203
wait-for-css: ("#help-button .popover", {"display": "block"})
204204
assert-css: ("#settings-menu .popover", {"display": "none"})
205205

206+
// Now switch back to the settings popover, and make sure the keyboard
207+
// shortcut works when a check box is selected.
208+
click: "#settings-menu > a"
209+
wait-for-css: ("#settings-menu .popover", {"display": "block"})
210+
focus: "#auto-hide-large-items"
211+
press-key: "?"
212+
wait-for-css: ("#settings-menu .popover", {"display": "none"})
213+
wait-for-css: ("#help-button .popover", {"display": "block"})
214+
215+
// Now switch back to the settings popover, and make sure the keyboard
216+
// shortcut works when a check box is selected.
217+
click: "#settings-menu > a"
218+
wait-for-css: ("#settings-menu .popover", {"display": "block"})
219+
wait-for-css: ("#help-button .popover", {"display": "none"})
220+
focus: "#theme-system-preference"
221+
press-key: "?"
222+
wait-for-css: ("#settings-menu .popover", {"display": "none"})
223+
wait-for-css: ("#help-button .popover", {"display": "block"})
224+
206225
// Now we go to the settings page to check that the CSS is loaded as expected.
207226
goto: "file://" + |DOC_PATH| + "/settings.html"
208227
wait-for: "#settings"

0 commit comments

Comments
 (0)