Rollup merge of #98646 - notriddle:notriddle/main.js, r=GuillaumeGomez
rustdoc: fix bugs in main.js popover help and settings
This commit is contained in:
commit
1fef19a216
3 changed files with 25 additions and 2 deletions
|
@ -412,14 +412,15 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (document.activeElement.tagName === "INPUT") {
|
if (document.activeElement.tagName === "INPUT" &&
|
||||||
|
document.activeElement.type !== "checkbox") {
|
||||||
switch (getVirtualKey(ev)) {
|
switch (getVirtualKey(ev)) {
|
||||||
case "Escape":
|
case "Escape":
|
||||||
handleEscape(ev);
|
handleEscape(ev);
|
||||||
|
@ -926,6 +927,7 @@ function loadCss(cssFileName) {
|
||||||
function showHelp() {
|
function showHelp() {
|
||||||
const menu = getHelpMenu(true);
|
const menu = getHelpMenu(true);
|
||||||
if (menu.style.display === "none") {
|
if (menu.style.display === "none") {
|
||||||
|
window.hidePopoverMenus();
|
||||||
menu.style.display = "";
|
menu.style.display = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -939,6 +941,8 @@ function loadCss(cssFileName) {
|
||||||
const shouldShowHelp = menu.style.display === "none";
|
const shouldShowHelp = menu.style.display === "none";
|
||||||
if (shouldShowHelp) {
|
if (shouldShowHelp) {
|
||||||
showHelp();
|
showHelp();
|
||||||
|
} else {
|
||||||
|
window.hidePopoverMenus();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,11 @@ click: "#help-button"
|
||||||
assert-css: ("#help-button .popover", {"display": "block"})
|
assert-css: ("#help-button .popover", {"display": "block"})
|
||||||
assert-css: ("#settings-menu .popover", {"display": "none"})
|
assert-css: ("#settings-menu .popover", {"display": "none"})
|
||||||
|
|
||||||
|
// Now verify that clicking the help menu again closes it.
|
||||||
|
click: "#help-button"
|
||||||
|
assert-css: ("#help-button .popover", {"display": "none"})
|
||||||
|
assert-css: ("#settings-menu .popover", {"display": "none"})
|
||||||
|
|
||||||
// We check the borders color now:
|
// We check the borders color now:
|
||||||
|
|
||||||
// Ayu theme
|
// Ayu theme
|
||||||
|
|
|
@ -121,6 +121,20 @@ 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: "Escape"
|
||||||
|
press-key: "?"
|
||||||
|
assert-false: "#help-button .popover"
|
||||||
|
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: "Escape"
|
||||||
|
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