Skip to content
Merged
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
5 changes: 5 additions & 0 deletions sphinx_fuma/static/fuma.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,11 @@
event.preventDefault();
window.location.href = active.href;
}
} else if (event.key === "Escape") {
// `<input type=search>` swallows the first Escape to clear itself, which
// would leave the dialog needing two presses despite the `Esc` hint.
event.preventDefault();
dialog.close();
}
});

Expand Down
6 changes: 6 additions & 0 deletions sphinx_fuma/tests/test_theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,12 @@ def test_toc_scroll_spy_marks_every_visible_item_active(self, built):
assert 'entry.item.classList.add("fd-active")' in script
assert 'active[0].item.classList.add("fd-active")' not in script

def test_escape_closes_the_search_dialog_on_the_first_press(self, built):
script = (built / "_static" / "fuma.js").read_text()
# `<input type=search>` eats the first Escape to clear itself, so the
# dialog has to close on it explicitly.
assert 'event.key === "Escape"' in script

def test_tight_list_paragraphs_do_not_expand_item_spacing(self, built):
stylesheet = (built / "_static" / "fuma.css").read_text()
assert (".fd-prose ul.simple > li > p,\n.fd-prose ol.simple > li > p {\n margin: 0;\n}") in stylesheet
Expand Down