Add icon to clear the current search

This commit is contained in:
John R. Supplee 2021-03-28 02:46:11 +02:00
parent 39b4ada26d
commit 20a2ea3e7a
2 changed files with 9 additions and 0 deletions

View file

@ -32,6 +32,7 @@ template(name="globalSearch")
.wrapper
form.global-search-page.js-search-query-form
input.global-search-query-input(
style="{# if hasResults.get #}display: inline-block;{#/if#}"
id="global-search-input"
type="text"
name="searchQuery"
@ -39,6 +40,7 @@ template(name="globalSearch")
value="{{ query.get }}"
autofocus dir="auto"
)
a.js-new-search.fa.fa-eraser
if searching.get
+spinner
else if hasResults.get

View file

@ -249,6 +249,13 @@ class GlobalSearchComponent extends CardSearchPagedComponent {
);
document.getElementById('global-search-input').focus();
},
'click .js-new-search'(evt) {
evt.preventDefault();
const input = document.getElementById('global-search-input');
input.value = '';
this.query.set('');
this.hasResults.set(false);
},
},
];
}