mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-11-12 01:50:52 +01:00
Fixed following of link if search input is focused
This commit is contained in:
parent
f6238f3bae
commit
7ae0a42654
3
material/assets/javascripts/application-6b599127bc.js
Normal file
3
material/assets/javascripts/application-6b599127bc.js
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -149,7 +149,7 @@
|
||||
{% endblock %}
|
||||
</div>
|
||||
{% block scripts %}
|
||||
<script src="{{ base_url }}/assets/javascripts/application-7018102a8b.js"></script>
|
||||
<script src="{{ base_url }}/assets/javascripts/application-6b599127bc.js"></script>
|
||||
<script>app.initialize({url:{base:"{{ base_url }}"}})</script>
|
||||
{% for path in extra_javascript %}
|
||||
<script src="{{ path }}"></script>
|
||||
|
@ -203,8 +203,8 @@ function initialize(config) { // eslint-disable-line func-style
|
||||
}
|
||||
}))
|
||||
|
||||
/* Listener: keyboard handlers */
|
||||
new Material.Event.Listener(window, "keydown", ev => {
|
||||
/* Listener: keyboard handlers */ // eslint-disable-next-line complexity
|
||||
new Material.Event.Listener(window, "keydown", ev => { // TODO: split up into component to reduce complexity
|
||||
const toggle = document.querySelector("[data-md-toggle=search]")
|
||||
if (!(toggle instanceof HTMLInputElement))
|
||||
throw new ReferenceError
|
||||
@ -221,9 +221,21 @@ function initialize(config) { // eslint-disable-line func-style
|
||||
|
||||
/* Enter: prevent form submission */
|
||||
if (ev.keyCode === 13) {
|
||||
if (query === document.activeElement)
|
||||
if (query === document.activeElement) {
|
||||
ev.preventDefault()
|
||||
|
||||
/* Go to current active/focused link */
|
||||
const focus = document.querySelector(
|
||||
"[data-md-component=search] [href][data-md-state=active]")
|
||||
if (focus instanceof HTMLLinkElement)
|
||||
window.location = focus.getAttribute("href")
|
||||
|
||||
/* Close search */
|
||||
toggle.checked = false
|
||||
toggle.dispatchEvent(new CustomEvent("change"))
|
||||
query.blur()
|
||||
}
|
||||
|
||||
/* Escape: close search */
|
||||
} else if (ev.keyCode === 27) {
|
||||
toggle.checked = false
|
||||
@ -299,16 +311,6 @@ function initialize(config) { // eslint-disable-line func-style
|
||||
}
|
||||
}).listen()
|
||||
|
||||
/* Listener: fix unclickable toggle due to blur handler */
|
||||
new Material.Event.MatchMedia("(min-width: 960px)",
|
||||
new Material.Event.Listener("[data-md-toggle=search]", "click",
|
||||
ev => ev.stopPropagation()))
|
||||
|
||||
/* Listener: prevent search from closing when clicking */
|
||||
new Material.Event.MatchMedia("(min-width: 960px)",
|
||||
new Material.Event.Listener("[data-md-component=search]", "click",
|
||||
ev => ev.stopPropagation()))
|
||||
|
||||
/* Retrieve facts for the given repository type */
|
||||
;(() => {
|
||||
const el = document.querySelector("[data-md-source]")
|
||||
|
Loading…
Reference in New Issue
Block a user