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

Fixed search hotkey stealing focus from non-form textarea

This commit is contained in:
squidfunk 2019-04-28 11:49:40 +02:00
parent 611dc9718f
commit b245e9f769
3 changed files with 9 additions and 4 deletions

View File

@ -190,7 +190,7 @@
{% endblock %}
</div>
{% block scripts %}
<script src="{{ 'assets/javascripts/application.bef98be6.js' | url }}"></script>
<script src="{{ 'assets/javascripts/application.8c0d971c.js' | url }}"></script>
{% if lang.t("search.language") != "en" %}
{% set languages = lang.t("search.language").split(",") %}
{% if languages | length and languages[0] != "" %}

View File

@ -341,7 +341,7 @@ function initialize(config) { // eslint-disable-line func-style
/* Skip editable elements */
if (document.activeElement instanceof HTMLElement &&
document.activeElement.contentEditable === "true")
document.activeElement.isContentEditable)
return
/* Abort if meta key (macOS) or ctrl key (Windows) is pressed */
@ -420,6 +420,11 @@ function initialize(config) { // eslint-disable-line func-style
/* Search is closed and we're not inside a form */
} else if (document.activeElement && !document.activeElement.form) {
/* Fixes #1026: search grabs focus for non-form input elements */
if (document.activeElement.tagName === "TEXTAREA" ||
document.activeElement.tagName === "INPUT")
return
/* F/S: Open search if not in input field */
if (ev.keyCode === 70 || ev.keyCode === 83) {
query.focus()