FEATURE: Add clear button to search bar

Previously you had to clear the search results out by deleting them.
This introduces a friendlier way to clear the search UX, especially if
you didn't find what you're looking for.
This commit is contained in:
Justin DiRose 2020-10-06 12:08:28 -05:00
parent abb9047d29
commit e3be3fbb77
No known key found for this signature in database
GPG Key ID: 4B811FB264021800
4 changed files with 21 additions and 1 deletions

View File

@ -11,5 +11,10 @@ export default Ember.Component.extend({
onSearchTermChange(term) {
this.debouncedSearch(term);
},
clearSearch() {
this.set("searchTerm", "");
this.onSearch("");
},
},
});

View File

@ -8,5 +8,10 @@
placeholder=(i18n "knowledge_explorer.search.placeholder")
autocapitalize="off"
}}
{{d-icon "search"}}
{{#if searchTerm}}
{{d-button action=(action "clearSearch") class="clear-search" label="knowledge_explorer.search.clear"}}
{{else}}
{{d-icon "search"}}
{{/if}}
</span>

View File

@ -13,6 +13,15 @@
display: none;
}
}
.btn.clear-search {
background-color: var(--secondary);
color: var(--tertiary);
font-size: .75em;
position: absolute;
right: 0.80em;
text-transform: lowercase;
top: 20%;
}
}
.knowledge-explorer-search {

View File

@ -13,6 +13,7 @@ en:
one: "%{count} result found"
other: "%{count} results found"
placeholder: "Search for topics"
clear: "Clear"
topic:
back: "Go back"
navigate_to_topic: "View the discussion on this topic"