Skip to content

Commit

Permalink
fix(typeahead): for editable false clear the value on input change
Browse files Browse the repository at this point in the history
- for editable false clear the value on input change instead of on suggestions fetched

Closes #3262
  • Loading branch information
IAfanasov committed Jun 29, 2019
1 parent b2b5361 commit 3a631ce
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions src/typeahead/typeahead.ts
Expand Up @@ -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$);
}

Expand Down

0 comments on commit 3a631ce

Please sign in to comment.