Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop gobbling escape key #12813

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,8 @@ Features added
Bugs fixed
----------

* #12813: Stop gobbling escape key
Patch by Gabriel Fouasnon.

Testing
-------
12 changes: 3 additions & 9 deletions sphinx/themes/basic/static/doctools.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@
*/
"use strict";

const BLACKLISTED_KEY_CONTROL_ELEMENTS = new Set([
"TEXTAREA",
"INPUT",
"SELECT",
"BUTTON",
]);

const _ready = (callback) => {
if (document.readyState !== "loading") {
callback();
Expand Down Expand Up @@ -104,8 +97,9 @@ const Documentation = {
return;

document.addEventListener("keydown", (event) => {
// bail for input elements
if (BLACKLISTED_KEY_CONTROL_ELEMENTS.has(document.activeElement.tagName)) return;
// bail if browser focus is on anything but a link (or the body)
const focusEl = document.activeElement;
if (focusEl && (focusEl !== document.body || focusEl.tagName !== "A")) return;
// bail with special keys
if (event.altKey || event.ctrlKey || event.metaKey) return;

Expand Down
5 changes: 3 additions & 2 deletions sphinx/themes/basic/static/sphinx_highlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,9 @@ const SphinxHighlight = {
if (!DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS) return;

document.addEventListener("keydown", (event) => {
// bail for input elements
if (BLACKLISTED_KEY_CONTROL_ELEMENTS.has(document.activeElement.tagName)) return;
// bail if browser focus is on anything but a link (or the body)
const focusEl = document.activeElement;
if (focusEl && (focusEl !== document.body || focusEl.tagName !== "A")) return;
// bail with special keys
if (event.shiftKey || event.altKey || event.ctrlKey || event.metaKey) return;
if (DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS && (event.key === "Escape")) {
Expand Down
Loading