Fixed search reset button not hiding for empty input

This commit is contained in:
squidfunk 2020-02-17 10:47:52 +01:00
parent c9d2e7774e
commit 2c0177ab56
12 changed files with 22 additions and 26 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,10 +1,10 @@
{ {
"assets/javascripts/bundle.js": "assets/javascripts/bundle.a111dfc8.min.js", "assets/javascripts/bundle.js": "assets/javascripts/bundle.af5dd3a5.min.js",
"assets/javascripts/bundle.js.map": "assets/javascripts/bundle.a111dfc8.min.js.map", "assets/javascripts/bundle.js.map": "assets/javascripts/bundle.af5dd3a5.min.js.map",
"assets/javascripts/worker/packer.js": "assets/javascripts/worker/packer.c14659e8.min.js", "assets/javascripts/worker/packer.js": "assets/javascripts/worker/packer.c14659e8.min.js",
"assets/javascripts/worker/packer.js.map": "assets/javascripts/worker/packer.c14659e8.min.js.map", "assets/javascripts/worker/packer.js.map": "assets/javascripts/worker/packer.c14659e8.min.js.map",
"assets/javascripts/worker/search.js": "assets/javascripts/worker/search.3144ce89.min.js", "assets/javascripts/worker/search.js": "assets/javascripts/worker/search.3144ce89.min.js",
"assets/javascripts/worker/search.js.map": "assets/javascripts/worker/search.3144ce89.min.js.map", "assets/javascripts/worker/search.js.map": "assets/javascripts/worker/search.3144ce89.min.js.map",
"assets/stylesheets/app-palette.scss": "assets/stylesheets/app-palette.8c25017f.min.css", "assets/stylesheets/app-palette.scss": "assets/stylesheets/app-palette.3f90c815.min.css",
"assets/stylesheets/app.scss": "assets/stylesheets/app.4918cd9c.min.css" "assets/stylesheets/app.scss": "assets/stylesheets/app.0ee2cfd0.min.css"
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -43,9 +43,9 @@
{% endif %} {% endif %}
{% endblock %} {% endblock %}
{% block styles %} {% block styles %}
<link rel="stylesheet" href="{{ 'assets/stylesheets/app.4918cd9c.min.css' | url }}"> <link rel="stylesheet" href="{{ 'assets/stylesheets/app.0ee2cfd0.min.css' | url }}">
{% if palette.primary or palette.accent %} {% if palette.primary or palette.accent %}
<link rel="stylesheet" href="{{ 'assets/stylesheets/app-palette.8c25017f.min.css' | url }}"> <link rel="stylesheet" href="{{ 'assets/stylesheets/app-palette.3f90c815.min.css' | url }}">
{% endif %} {% endif %}
{% if palette.primary %} {% if palette.primary %}
{% import "partials/palette.html" as map %} {% import "partials/palette.html" as map %}
@ -190,7 +190,7 @@
{% endblock %} {% endblock %}
</div> </div>
{% block scripts %} {% block scripts %}
<script src="{{ 'assets/javascripts/bundle.a111dfc8.min.js' | url }}"></script> <script src="{{ 'assets/javascripts/bundle.af5dd3a5.min.js' | url }}"></script>
<script id="__lang" type="application/json"> <script id="__lang" type="application/json">
{%- set translations = {} -%} {%- set translations = {} -%}
{%- for key in [ {%- for key in [

View File

@ -6,7 +6,7 @@
<label class="md-search__overlay" for="__search"></label> <label class="md-search__overlay" for="__search"></label>
<div class="md-search__inner" role="search"> <div class="md-search__inner" role="search">
<form class="md-search__form" name="search"> <form class="md-search__form" name="search">
<input type="text" class="md-search__input" name="query" placeholder="{{ lang.t('search.placeholder') }}" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="search-query" data-md-state="active"> <input type="text" class="md-search__input" name="query" placeholder="{{ lang.t('search.placeholder') }}" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="search-query" data-md-state="active" required>
<label class="md-icon md-search__icon" for="__search"></label> <label class="md-icon md-search__icon" for="__search"></label>
<button type="reset" class="md-icon md-search__icon" data-md-component="search-reset" tabindex="-1"> <button type="reset" class="md-icon md-search__icon" data-md-component="search-reset" tabindex="-1">
&#xE5CD; &#xE5CD;

View File

@ -21,13 +21,7 @@
*/ */
import { OperatorFunction, pipe } from "rxjs" import { OperatorFunction, pipe } from "rxjs"
import { import { mapTo, switchMap, switchMapTo, tap } from "rxjs/operators"
mapTo,
startWith,
switchMap,
switchMapTo,
tap
} from "rxjs/operators"
import { setElementFocus, watchSearchReset } from "observables" import { setElementFocus, watchSearchReset } from "observables"
@ -43,12 +37,13 @@ import { useComponent } from "../../_"
* @return Operator function * @return Operator function
*/ */
export function mountSearchReset(): OperatorFunction<HTMLElement, void> { export function mountSearchReset(): OperatorFunction<HTMLElement, void> {
const query$ = useComponent<HTMLElement>("search-query")
return pipe( return pipe(
switchMap(watchSearchReset), switchMap(el => watchSearchReset(el)
switchMapTo(query$), .pipe(
tap(setElementFocus), switchMapTo(useComponent("search-query")),
mapTo(undefined), tap(setElementFocus),
startWith(undefined) mapTo(undefined)
)
)
) )
} }

View File

@ -38,6 +38,7 @@
spellcheck="false" spellcheck="false"
data-md-component="search-query" data-md-component="search-query"
data-md-state="active" data-md-state="active"
required
/> />
<label class="md-icon md-search__icon" for="__search"></label> <label class="md-icon md-search__icon" for="__search"></label>
<button <button