diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index 2d2de7db0c9..789e7d298fa 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -412,9 +412,9 @@ function loadCss(cssFileName) { window.hidePopoverMenus(); } - const disableShortcuts = getSettingValue("disable-shortcuts") === "true"; function handleShortcut(ev) { // Don't interfere with browser shortcuts + const disableShortcuts = getSettingValue("disable-shortcuts") === "true"; if (ev.ctrlKey || ev.altKey || ev.metaKey || disableShortcuts) { return; } diff --git a/src/test/rustdoc-gui/settings.goml b/src/test/rustdoc-gui/settings.goml index 237a4751a8d..a43c712ef9a 100644 --- a/src/test/rustdoc-gui/settings.goml +++ b/src/test/rustdoc-gui/settings.goml @@ -121,6 +121,17 @@ local-storage: {"rustdoc-disable-shortcuts": "false"} click: ".setting-line:last-child .toggle .label" assert-local-storage: {"rustdoc-disable-shortcuts": "true"} +// Make sure that "Disable keyboard shortcuts" actually took effect. +press-key: "?" +wait-for-css: ("#settings-menu .popover", {"display": "block"}) + +// Now turn keyboard shortcuts back on, and see if they work. +click: ".setting-line:last-child .toggle .label" +assert-local-storage: {"rustdoc-disable-shortcuts": "false"} +press-key: "?" +wait-for-css: ("#help-button .popover", {"display": "block"}) +assert-css: ("#settings-menu .popover", {"display": "none"}) + // 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"