Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustdoc: fix corner cases with "?" JS keyboard command #107042

Merged
merged 2 commits into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/librustdoc/html/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,8 @@ function loadCss(cssUrl) {
}

if (document.activeElement.tagName === "INPUT" &&
document.activeElement.type !== "checkbox") {
document.activeElement.type !== "checkbox" &&
document.activeElement.type !== "radio") {
switch (getVirtualKey(ev)) {
case "Escape":
handleEscape(ev);
Expand Down Expand Up @@ -1082,6 +1083,9 @@ function loadCss(cssUrl) {
* Show the help popup menu.
*/
function showHelp() {
// Prevent `blur` events from being dispatched as a result of closing
// other modals.
getHelpButton().querySelector("a").focus();
const menu = getHelpMenu(true);
if (menu.style.display === "none") {
window.hideAllModals();
Expand Down
19 changes: 19 additions & 0 deletions tests/rustdoc-gui/settings.goml
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,25 @@ press-key: "?"
wait-for-css: ("#help-button .popover", {"display": "block"})
assert-css: ("#settings-menu .popover", {"display": "none"})

// Now switch back to the settings popover, and make sure the keyboard
// shortcut works when a check box is selected.
click: "#settings-menu > a"
wait-for-css: ("#settings-menu .popover", {"display": "block"})
focus: "#auto-hide-large-items"
press-key: "?"
wait-for-css: ("#settings-menu .popover", {"display": "none"})
wait-for-css: ("#help-button .popover", {"display": "block"})

// Now switch back to the settings popover, and make sure the keyboard
// shortcut works when a check box is selected.
click: "#settings-menu > a"
wait-for-css: ("#settings-menu .popover", {"display": "block"})
wait-for-css: ("#help-button .popover", {"display": "none"})
focus: "#theme-system-preference"
press-key: "?"
wait-for-css: ("#settings-menu .popover", {"display": "none"})
wait-for-css: ("#help-button .popover", {"display": "block"})

// Now we go to the settings page to check that the CSS is loaded as expected.
goto: "file://" + |DOC_PATH| + "/settings.html"
wait-for: "#settings"
Expand Down