1
0
mirror of https://github.com/squidfunk/mkdocs-material.git synced 2024-11-12 01:50:52 +01:00

Keep search open on enter without selection

This commit is contained in:
Lukas Geiter 2017-10-12 16:04:48 +02:00 committed by Martin Donath
parent a267729084
commit 253596c58d
4 changed files with 10 additions and 9 deletions

View File

@ -39,7 +39,7 @@
<script src="{{ base_url }}/assets/javascripts/modernizr-e826f8942a.js"></script>
{% endblock %}
{% block styles %}
<link rel="stylesheet" href="{{ base_url }}/assets/stylesheets/application-9011e2d3f8.css">
<link rel="stylesheet" href="{{ base_url }}/assets/stylesheets/application-4d315b386e.css">
{% if config.extra.palette %}
<link rel="stylesheet" href="{{ base_url }}/assets/stylesheets/application-23f75ab9c7.palette.css">
{% endif %}
@ -153,7 +153,7 @@
{% endblock %}
</div>
{% block scripts %}
<script src="{{ base_url }}/assets/javascripts/application-f3ab9e5ff8.js"></script>
<script src="{{ base_url }}/assets/javascripts/application-683e1b679e.js"></script>
{% set languages = lang.t("search.languages").split(",") %}
{% if languages | length and languages[0] != "" %}
{% set path = base_url + "/assets/javascripts/lunr" %}

View File

@ -290,13 +290,14 @@ function initialize(config) { // eslint-disable-line func-style
/* Go to current active/focused link */
const focus = document.querySelector(
"[data-md-component=search] [href][data-md-state=active]")
if (focus instanceof HTMLLinkElement)
if (focus instanceof HTMLLinkElement) {
window.location = focus.getAttribute("href")
/* Close search */
toggle.checked = false
toggle.dispatchEvent(new CustomEvent("change"))
query.blur()
/* Close search */
toggle.checked = false
toggle.dispatchEvent(new CustomEvent("change"))
query.blur()
}
}
/* Escape: close search */