rustdoc: put focus on the help link when opening it from keyboard
This prevents some strange blur-event-related bugs with the "?" command by ensuring that the focus remains in the same spot when the settings area closes.
This commit is contained in:
parent
1f72129ffe
commit
deb05758c8
2 changed files with 12 additions and 0 deletions
|
@ -1082,6 +1082,9 @@ function loadCss(cssUrl) {
|
||||||
* Show the help popup menu.
|
* Show the help popup menu.
|
||||||
*/
|
*/
|
||||||
function showHelp() {
|
function showHelp() {
|
||||||
|
// Prevent `blur` events from being dispatched as a result of closing
|
||||||
|
// other modals.
|
||||||
|
getHelpButton().querySelector("a").focus();
|
||||||
const menu = getHelpMenu(true);
|
const menu = getHelpMenu(true);
|
||||||
if (menu.style.display === "none") {
|
if (menu.style.display === "none") {
|
||||||
window.hideAllModals();
|
window.hideAllModals();
|
||||||
|
|
|
@ -203,6 +203,15 @@ press-key: "?"
|
||||||
wait-for-css: ("#help-button .popover", {"display": "block"})
|
wait-for-css: ("#help-button .popover", {"display": "block"})
|
||||||
assert-css: ("#settings-menu .popover", {"display": "none"})
|
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 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
Reference in a new issue