File tree Expand file tree Collapse file tree 3 files changed +25
-2
lines changed
librustdoc/html/static/js Expand file tree Collapse file tree 3 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -412,14 +412,15 @@ function loadCss(cssFileName) {
412412 window . hidePopoverMenus ( ) ;
413413 }
414414
415- const disableShortcuts = getSettingValue ( "disable-shortcuts" ) === "true" ;
416415 function handleShortcut ( ev ) {
417416 // Don't interfere with browser shortcuts
417+ const disableShortcuts = getSettingValue ( "disable-shortcuts" ) === "true" ;
418418 if ( ev . ctrlKey || ev . altKey || ev . metaKey || disableShortcuts ) {
419419 return ;
420420 }
421421
422- if ( document . activeElement . tagName === "INPUT" ) {
422+ if ( document . activeElement . tagName === "INPUT" &&
423+ document . activeElement . type !== "checkbox" ) {
423424 switch ( getVirtualKey ( ev ) ) {
424425 case "Escape" :
425426 handleEscape ( ev ) ;
@@ -926,6 +927,7 @@ function loadCss(cssFileName) {
926927 function showHelp ( ) {
927928 const menu = getHelpMenu ( true ) ;
928929 if ( menu . style . display === "none" ) {
930+ window . hidePopoverMenus ( ) ;
929931 menu . style . display = "" ;
930932 }
931933 }
@@ -939,6 +941,8 @@ function loadCss(cssFileName) {
939941 const shouldShowHelp = menu . style . display === "none" ;
940942 if ( shouldShowHelp ) {
941943 showHelp ( ) ;
944+ } else {
945+ window . hidePopoverMenus ( ) ;
942946 }
943947 } ) ;
944948
Original file line number Diff line number Diff line change @@ -24,6 +24,11 @@ click: "#help-button"
2424assert-css: ("#help-button .popover", {"display": "block"})
2525assert-css: ("#settings-menu .popover", {"display": "none"})
2626
27+ // Now verify that clicking the help menu again closes it.
28+ click: "#help-button"
29+ assert-css: ("#help-button .popover", {"display": "none"})
30+ assert-css: ("#settings-menu .popover", {"display": "none"})
31+
2732// We check the borders color now:
2833
2934// Ayu theme
Original file line number Diff line number Diff line change @@ -121,6 +121,20 @@ local-storage: {"rustdoc-disable-shortcuts": "false"}
121121click: ".setting-line:last-child .toggle .label"
122122assert-local-storage: {"rustdoc-disable-shortcuts": "true"}
123123
124+ // Make sure that "Disable keyboard shortcuts" actually took effect.
125+ press-key: "Escape"
126+ press-key: "?"
127+ assert-false: "#help-button .popover"
128+ wait-for-css: ("#settings-menu .popover", {"display": "block"})
129+
130+ // Now turn keyboard shortcuts back on, and see if they work.
131+ click: ".setting-line:last-child .toggle .label"
132+ assert-local-storage: {"rustdoc-disable-shortcuts": "false"}
133+ press-key: "Escape"
134+ press-key: "?"
135+ wait-for-css: ("#help-button .popover", {"display": "block"})
136+ assert-css: ("#settings-menu .popover", {"display": "none"})
137+
124138// Now we go to the settings page to check that the CSS is loaded as expected.
125139goto: file://|DOC_PATH|/settings.html
126140wait-for: "#settings"
You can’t perform that action at this time.
0 commit comments