From 3a631cef4e1b1332ec470bf6e95deadf0f7b86f2 Mon Sep 17 00:00:00 2001 From: IAfanasov Date: Sat, 29 Jun 2019 12:52:02 +0200 Subject: [PATCH] fix(typeahead): for editable false clear the value on input change - for editable false clear the value on input change instead of on suggestions fetched Closes #3262 --- src/typeahead/typeahead.ts | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/typeahead/typeahead.ts b/src/typeahead/typeahead.ts index c53543b469..f91589eb71 100644 --- a/src/typeahead/typeahead.ts +++ b/src/typeahead/typeahead.ts @@ -219,17 +219,10 @@ export class NgbTypeahead implements ControlValueAccessor, ngOnInit(): void { const inputValues$ = this._valueChanges.pipe(tap(value => { this._inputValueBackup = this.showHint ? value : null; - if (this.editable) { - this._onChange(value); - } + this._onChange(this.editable ? value : undefined); })); const results$ = inputValues$.pipe(this.ngbTypeahead); - const processedResults$ = results$.pipe(tap(() => { - if (!this.editable) { - this._onChange(undefined); - } - })); - const userInput$ = this._resubscribeTypeahead.pipe(switchMap(() => processedResults$)); + const userInput$ = this._resubscribeTypeahead.pipe(switchMap(() => results$)); this._subscription = this._subscribeToUserInput(userInput$); }