add button to clear search
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -28,7 +28,7 @@ export function SearchModal<T>(
|
|||||||
<div>
|
<div>
|
||||||
<main>
|
<main>
|
||||||
<h2>{headline}</h2>
|
<h2>{headline}</h2>
|
||||||
<div class="flex-row width-input">
|
<div class="flex-row">
|
||||||
<input
|
<input
|
||||||
id="focused"
|
id="focused"
|
||||||
placeholder={
|
placeholder={
|
||||||
@@ -46,6 +46,17 @@ export function SearchModal<T>(
|
|||||||
StringToOption,
|
StringToOption,
|
||||||
]}
|
]}
|
||||||
></datalist>
|
></datalist>
|
||||||
|
<button
|
||||||
|
class="standard"
|
||||||
|
aria-label={
|
||||||
|
coreViewModel.translations.general
|
||||||
|
.searchButtonClearAudioLabel
|
||||||
|
}
|
||||||
|
on:click={searchViewModel.clear}
|
||||||
|
toggle:disabled={searchViewModel.cannotClear}
|
||||||
|
>
|
||||||
|
<span class="icon">close</span>
|
||||||
|
</button>
|
||||||
<button
|
<button
|
||||||
class="primary"
|
class="primary"
|
||||||
aria-label={
|
aria-label={
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ const englishTranslations = {
|
|||||||
general: {
|
general: {
|
||||||
deleteItemButtonAudioLabel: "delete item",
|
deleteItemButtonAudioLabel: "delete item",
|
||||||
searchButtonAudioLabel: "search",
|
searchButtonAudioLabel: "search",
|
||||||
|
searchButtonClearAudioLabel: "clear search query",
|
||||||
|
|
||||||
abortButton: "Abort",
|
abortButton: "Abort",
|
||||||
cancelButton: "Cancel",
|
cancelButton: "Cancel",
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -18,6 +18,10 @@ export default class SearchViewModel<T> {
|
|||||||
[this.searchInput, this.appliedQuery],
|
[this.searchInput, this.appliedQuery],
|
||||||
() => this.searchInput.value == this.appliedQuery.value,
|
() => this.searchInput.value == this.appliedQuery.value,
|
||||||
);
|
);
|
||||||
|
cannotClear: React.State<boolean> = React.createProxyState(
|
||||||
|
[this.searchInput],
|
||||||
|
() => this.searchInput.value == "",
|
||||||
|
);
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
search = (searchTerm: string): void => {
|
search = (searchTerm: string): void => {
|
||||||
@@ -37,6 +41,10 @@ export default class SearchViewModel<T> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
clear = (): void => {
|
||||||
|
this.searchInput.value = "";
|
||||||
|
}
|
||||||
|
|
||||||
// init
|
// init
|
||||||
constructor(
|
constructor(
|
||||||
allObjects: React.ListState<T> | React.MapState<T>,
|
allObjects: React.ListState<T> | React.MapState<T>,
|
||||||
|
|||||||
Reference in New Issue
Block a user