diff --git a/dmp-frontend/src/app/library/auto-complete/multiple/multiple-auto-complete.component.ts b/dmp-frontend/src/app/library/auto-complete/multiple/multiple-auto-complete.component.ts index a47d338c0..8974c1ba8 100644 --- a/dmp-frontend/src/app/library/auto-complete/multiple/multiple-auto-complete.component.ts +++ b/dmp-frontend/src/app/library/auto-complete/multiple/multiple-auto-complete.component.ts @@ -307,7 +307,6 @@ export class MultipleAutoCompleteComponent extends _CustomComponentMixinBase imp startWith(null), debounceTime(this.requestDelay), distinctUntilChanged(), - distinctUntilChanged(), mergeMap(query => this.filter(query)), catchError(error => { this._items = null; diff --git a/dmp-frontend/src/app/library/auto-complete/single/single-auto-complete.component.html b/dmp-frontend/src/app/library/auto-complete/single/single-auto-complete.component.html index 40f4f6ace..9f231ecb1 100644 --- a/dmp-frontend/src/app/library/auto-complete/single/single-auto-complete.component.html +++ b/dmp-frontend/src/app/library/auto-complete/single/single-auto-complete.component.html @@ -37,7 +37,7 @@ - No results found! + No results found! @@ -45,4 +45,4 @@ - + \ No newline at end of file diff --git a/dmp-frontend/src/app/library/auto-complete/single/single-auto-complete.component.ts b/dmp-frontend/src/app/library/auto-complete/single/single-auto-complete.component.ts index 101bfaf98..8a34d8dd0 100644 --- a/dmp-frontend/src/app/library/auto-complete/single/single-auto-complete.component.ts +++ b/dmp-frontend/src/app/library/auto-complete/single/single-auto-complete.component.ts @@ -8,8 +8,8 @@ import { MatFormFieldControl } from '@angular/material/form-field'; import { AutoCompleteGroup } from '@app/library/auto-complete/auto-complete-group'; import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration'; import { BaseComponent } from '@common/base/base.component'; -import { Observable, Subject, of as observableOf } from 'rxjs'; -import { debounceTime, distinctUntilChanged, map, startWith, switchMap, takeUntil, tap } from 'rxjs/operators'; +import { Observable, Subject, of as observableOf, of } from 'rxjs'; +import { catchError, debounceTime, distinctUntilChanged, map, mergeMap, startWith, switchMap, takeUntil, tap } from 'rxjs/operators'; export class CustomComponentBase extends BaseComponent { @@ -64,8 +64,6 @@ export class SingleAutoCompleteComponent extends _CustomComponentMixinBase imple _groupedItems: Observable; _selectedItems: Map = new Map(); - queryValue: string = ""; - get empty() { return (this.value == null) && (!this.inputValue || this.inputValue.length === 0); } get shouldLabelFloat() { return this.focused || !this.empty; } @@ -220,7 +218,7 @@ export class SingleAutoCompleteComponent extends _CustomComponentMixinBase imple // prevent filtering results if arrow were pressed if (event.keyCode !== ENTER && (event.keyCode < 37 || event.keyCode > 40)) { if (this.inputValue.length === 0 && this.value != null) { - this.optionSelectedInternal(null); + this._onInputFocus(); } this._inputSubject.next(this.inputValue); } @@ -237,9 +235,13 @@ export class SingleAutoCompleteComponent extends _CustomComponentMixinBase imple startWith(null), debounceTime(this.requestDelay), distinctUntilChanged(), - tap(query => this.queryValue = query), - switchMap(query => this.filter(query))); - + mergeMap(query => this.filter(query)), + catchError(error => { + this._items = null; + console.error(error); + return of(null) + }) + ); if (this.configuration.groupingFn) { this._groupedItems = this._items.pipe(map(items => this.configuration.groupingFn(items))); } } }