rustdoc: fix keyboard shortcuts bug in settings menu
This commit fixes the keyboard shorts code to call localStorage every time a key is pressed. This matters because you're supposed to be able to change a setting and have it immediately take effect.
This commit is contained in:
parent
cec6988a07
commit
cb8a7388fa
2 changed files with 12 additions and 1 deletions
|
@ -412,9 +412,9 @@ function loadCss(cssFileName) {
|
||||||
window.hidePopoverMenus();
|
window.hidePopoverMenus();
|
||||||
}
|
}
|
||||||
|
|
||||||
const disableShortcuts = getSettingValue("disable-shortcuts") === "true";
|
|
||||||
function handleShortcut(ev) {
|
function handleShortcut(ev) {
|
||||||
// Don't interfere with browser shortcuts
|
// Don't interfere with browser shortcuts
|
||||||
|
const disableShortcuts = getSettingValue("disable-shortcuts") === "true";
|
||||||
if (ev.ctrlKey || ev.altKey || ev.metaKey || disableShortcuts) {
|
if (ev.ctrlKey || ev.altKey || ev.metaKey || disableShortcuts) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,6 +121,17 @@ local-storage: {"rustdoc-disable-shortcuts": "false"}
|
||||||
click: ".setting-line:last-child .toggle .label"
|
click: ".setting-line:last-child .toggle .label"
|
||||||
assert-local-storage: {"rustdoc-disable-shortcuts": "true"}
|
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.
|
// Now we go to the settings page to check that the CSS is loaded as expected.
|
||||||
goto: file://|DOC_PATH|/settings.html
|
goto: file://|DOC_PATH|/settings.html
|
||||||
wait-for: "#settings"
|
wait-for: "#settings"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue