From c8742dd9ea1e86e3a62ea6559abeec8859fc456d Mon Sep 17 00:00:00 2001 From: Max Ehrlicher-Schmidt Date: Fri, 18 Dec 2020 16:52:40 +0100 Subject: [PATCH] Fix reference table --- .../autocomplete-select.component.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/app/components/autocomplete-select/autocomplete-select.component.ts b/src/app/components/autocomplete-select/autocomplete-select.component.ts index 4a8cd97..319c1f0 100644 --- a/src/app/components/autocomplete-select/autocomplete-select.component.ts +++ b/src/app/components/autocomplete-select/autocomplete-select.component.ts @@ -18,7 +18,9 @@ export class AutocompleteSelectComponent implements OnInit { @Input() set possibleObjects(objects: any[]) { this._possibleObjects = objects; - this.filterPossibleObjects(); + setTimeout(() => { + this.filterPossibleObjects(); + }); } get possibleObjects(): any[] { return this._possibleObjects; @@ -69,13 +71,14 @@ export class AutocompleteSelectComponent implements OnInit { } onOptionSelected(element: any, trigger: MatAutocompleteTrigger) { - if (this.keepAutocompleteOpenAfterClick) { - trigger.openPanel(); - } - this.addForm.get('addGroup').setValue(''); + setTimeout(() => { + this.addForm.get('addGroup').reset(); + if (this.keepAutocompleteOpenAfterClick) { + trigger.openPanel(); + } + this.filterPossibleObjects(); + }); this.selectedElementChange.emit(element); - - this.filterPossibleObjects(); } filterPossibleObjects() { @@ -87,7 +90,7 @@ export class AutocompleteSelectComponent implements OnInit { if (!searchString) { return; } - searchString = searchString.toLocaleLowerCase(); + searchString = searchString.toLocaleLowerCase().trim(); this.filteredPossibleObjects = this.filteredPossibleObjects.filter( (element) => this.nameToShowInSelection(element)