Skip to content

Commit 90c7c63

Browse files
committed
Add comment describing the Escape key weirdness
1 parent 6918a17 commit 90c7c63

File tree

1 file changed

+8
-2
lines changed
  • src/librustdoc/html/render

1 file changed

+8
-2
lines changed

src/librustdoc/html/render/mod.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,7 @@ function handleThemeButtonsBlur(e) {{
807807
}}
808808
}}
809809
810-
function handleThemeKeyPress(e) {{
810+
function handleThemeKeyDown(e) {{
811811
if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) {{ return; }}
812812
if (!themePicker.parentNode.contains(e.target)) {{ return; }}
813813
var active = document.activeElement;
@@ -847,12 +847,18 @@ function handleThemeKeyPress(e) {{
847847
e.preventDefault();
848848
themes.lastElementChild.focus();
849849
break;
850+
// The escape key is handled in main.js, instead of here, for two reasons:
851+
//
852+
// 1 Escape should close the menu, even if it's not focused.
853+
// 2 The escape event handler is bound to both keydown and keypress, to work
854+
// around browser inconsistencies. That sort of logic doesn't apply to the
855+
// rest of these keybindings.
850856
}}
851857
}};
852858
853859
themePicker.onclick = switchThemeButtonState;
854860
themePicker.onblur = handleThemeButtonsBlur;
855-
document.addEventListener("keydown", handleThemeKeyPress);
861+
document.addEventListener("keydown", handleThemeKeyDown);
856862
{}.forEach(function(item) {{
857863
var but = document.createElement("button");
858864
but.textContent = item;

0 commit comments

Comments
 (0)