Skip to content

Commit

Permalink
fix: suggestions could be empty array (#328)
Browse files Browse the repository at this point in the history
  • Loading branch information
JounQin authored Apr 12, 2022
1 parent fdacd10 commit 8ff6976
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/sour-rabbits-relax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@alauda/ui": patch
---

fix: suggestions could be empty array
6 changes: 4 additions & 2 deletions src/autocomplete/autocomplete.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
ViewChild,
ViewEncapsulation,
} from '@angular/core';
import { Observable, ReplaySubject, combineLatest } from 'rxjs';
import { Observable, ReplaySubject, combineLatest, of } from 'rxjs';
import {
debounceTime,
distinctUntilChanged,
Expand Down Expand Up @@ -58,7 +58,9 @@ export class AutocompleteComponent implements AfterContentInit {
this.hasVisibleSuggestion$ = this.suggestions.changes.pipe(
startWith(this.suggestions),
switchMap((suggestions: QueryList<SuggestionComponent>) =>
combineLatest(suggestions.map(suggestion => suggestion.visible$)),
suggestions.length > 0
? combineLatest(suggestions.map(suggestion => suggestion.visible$))
: of([] as boolean[]),
),
map(visible => visible.some(Boolean)),
distinctUntilChanged(),
Expand Down

0 comments on commit 8ff6976

Please sign in to comment.