mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Automatically focus and bring up keyboard on touch devices
This commit is contained in:
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -250,7 +250,7 @@
|
|||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
<script src="{{ 'assets/javascripts/bundle.4e31edb1.min.js' | url }}"></script>
|
<script src="{{ 'assets/javascripts/bundle.9e673e97.min.js' | url }}"></script>
|
||||||
{% for script in config.extra_javascript %}
|
{% for script in config.extra_javascript %}
|
||||||
{% if script.path %}
|
{% if script.path %}
|
||||||
{{ script | script_tag }}
|
{{ script | script_tag }}
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ import {
|
|||||||
} from "rxjs"
|
} from "rxjs"
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
getElement,
|
||||||
getLocation,
|
getLocation,
|
||||||
setToggle,
|
setToggle,
|
||||||
watchElementFocus,
|
watchElementFocus,
|
||||||
@@ -186,6 +187,14 @@ export function mountSearchQuery(
|
|||||||
)
|
)
|
||||||
.subscribe(() => el.focus())
|
.subscribe(() => el.focus())
|
||||||
|
|
||||||
|
// Focus search query on label click - note that this is necessary to bring
|
||||||
|
// up the keyboard on iOS and other mobile platforms, as the search dialog is
|
||||||
|
// not visible at first, and programatically focusing an input element must
|
||||||
|
// be triggered by a user interaction - see https://t.ly/Cb30n
|
||||||
|
const label = getElement("header [for=__search]")
|
||||||
|
fromEvent(label, "click")
|
||||||
|
.subscribe(() => el.focus())
|
||||||
|
|
||||||
/* Create and return component */
|
/* Create and return component */
|
||||||
return watchSearchQuery(el, { worker$ })
|
return watchSearchQuery(el, { worker$ })
|
||||||
.pipe(
|
.pipe(
|
||||||
|
|||||||
Reference in New Issue
Block a user