Clear last search term when clear button clicked

This commit is contained in:
Michael Shamoon
2021-03-24 12:37:26 -07:00
parent 904ff04f1d
commit f399458df8
4 changed files with 9 additions and 7 deletions

View File

@@ -11,7 +11,8 @@
bindValue="id"
(change)="onChange(value)"
(search)="onSearch($event)"
(focus)="onFocus()"
(focus)="clearLastSearchTerm()"
(clear)="clearLastSearchTerm()"
(blur)="onBlur()">
</ng-select>

View File

@@ -52,10 +52,10 @@ export class SelectComponent extends AbstractInputComponent<number> {
clickNew() {
this.createNew.next(this._lastSearchTerm)
this._lastSearchTerm = null
this.clearLastSearchTerm()
}
onFocus() {
clearLastSearchTerm() {
this._lastSearchTerm = null
}
@@ -65,7 +65,7 @@ export class SelectComponent extends AbstractInputComponent<number> {
onBlur() {
setTimeout(() => {
this._lastSearchTerm = null
this.clearLastSearchTerm()
}, 3000);
}