mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Added automatic removal of query parameter when search is closed
This commit is contained in:
parent
5acd0c3620
commit
e3c26215de
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -213,7 +213,7 @@
|
|||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
<script src="{{ 'assets/javascripts/bundle.8aa65030.min.js' | url }}"></script>
|
<script src="{{ 'assets/javascripts/bundle.cd6d3f86.min.js' | url }}"></script>
|
||||||
{% for path in config["extra_javascript"] %}
|
{% for path in config["extra_javascript"] %}
|
||||||
<script src="{{ path | url }}"></script>
|
<script src="{{ path | url }}"></script>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -16,5 +16,5 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
{{ super() }}
|
{{ super() }}
|
||||||
<script src="{{ 'overrides/assets/javascripts/bundle.90528257.min.js' | url }}"></script>
|
<script src="{{ 'overrides/assets/javascripts/bundle.068fb875.min.js' | url }}"></script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -44,7 +44,8 @@ import { translation } from "~/_"
|
|||||||
import {
|
import {
|
||||||
getLocation,
|
getLocation,
|
||||||
setToggle,
|
setToggle,
|
||||||
watchElementFocus
|
watchElementFocus,
|
||||||
|
watchToggle
|
||||||
} from "~/browser"
|
} from "~/browser"
|
||||||
import {
|
import {
|
||||||
SearchMessageType,
|
SearchMessageType,
|
||||||
@ -101,6 +102,18 @@ export function watchSearchQuery(
|
|||||||
map(() => searchParams.get("q") || "")
|
map(() => searchParams.get("q") || "")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/* Remove query parameter when search is closed */
|
||||||
|
watchToggle("search")
|
||||||
|
.pipe(
|
||||||
|
filter(active => !active),
|
||||||
|
take(1)
|
||||||
|
)
|
||||||
|
.subscribe(() => {
|
||||||
|
const url = new URL(location.href)
|
||||||
|
url.searchParams.delete("q")
|
||||||
|
history.replaceState({}, "", `${url}`)
|
||||||
|
})
|
||||||
|
|
||||||
/* Set query from parameter */
|
/* Set query from parameter */
|
||||||
param$.subscribe(value => { // TODO: not ideal - find a better way
|
param$.subscribe(value => { // TODO: not ideal - find a better way
|
||||||
if (value)
|
if (value)
|
||||||
|
@ -84,7 +84,7 @@ export function mountIconSearchQuery(
|
|||||||
)
|
)
|
||||||
.subscribe(([, value]) => {
|
.subscribe(([, value]) => {
|
||||||
const path = document.location.pathname
|
const path = document.location.pathname
|
||||||
if (value.length)
|
if (typeof ga === "function" && value.length)
|
||||||
ga("send", "pageview", `${path}?q=[icon]+${value}`)
|
ga("send", "pageview", `${path}?q=[icon]+${value}`)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user