1

API is returning response as expected. But for some reason, suggestions are not displayed in the dropdown. No errors or warnings in the console and just freezing the screen.

Spent countless hours trying to debug but realized another pair of eyes will help. Any help will be appreciated.

HTML Code:

<input id="cust-typeahead-prevent-manual-entry" type="text" [ngClass]="[custSearchingYn == 'Y' ? 'form-control form-control-sm typeahead-loading' : 'form-control form-control-sm']" 
[(ngModel)]="search.custModel" [inputFormatter]="custFormatter" (selectItem)="customerSelected($event)"  [showHint]="true"
 [resultFormatter]="custFormatter" [editable]='false' [ngbTypeahead]="searchCust" placeholder="Customer Search" />

Angular:

searchCust: OperatorFunction<string, readonly Customer[]> = (text$: Observable<string>) => 
text$.pipe(
  debounceTime(200),
  distinctUntilChanged(),
  tap(() => (this.custSearchingYn = 'Y')),
  // switchMap allows returning an observable rather than maps array
  switchMap((searchCustStr) => searchCustStr.length <= 3 ? [] :this.custService.searchCustomers('QUOTE_SEARCH',
    searchCustStr).
    pipe(
      tap(() => (
        this.custSearcFailed = false)),
      catchError(() => {
        this.custSearcFailed = true;
        console.log('Error:');
        return of([]);
      }),  
    ),
  ),
  tap(() => (this.custSearchingYn = 'N'))
);

API Call:

searchCustomers(searchContext:string, searchStr: string): Observable<Customer[]> {
   return this.http.get<Customer[]>(`${environment.apiUrl}/api/customer/list/` + searchContext + `/` + searchStr)
   .pipe(map((response) =>  {
    console.log(JSON.stringify(response));
    return response}));
}
Phani
  • 5,319
  • 6
  • 35
  • 43

1 Answers1

0

Keycloak-angular library part of the project is causing the inconsistency behavior. Replaced with angular-oauth-oidc library and then everything started working now.

Phani
  • 5,319
  • 6
  • 35
  • 43