Skip to content

Commit

Permalink
fix: autocomplete empty suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
fengtianze committed Aug 5, 2024
1 parent 0f37437 commit e9eca03
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
5 changes: 3 additions & 2 deletions src/autocomplete/autocomplete.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,17 @@ export class AutocompleteComponent implements AfterContentInit {

ngAfterContentInit() {
this.visibles$ = this.suggestions.changes.pipe(
startWith(this.suggestions),
switchMap((suggestions: QueryList<SuggestionComponent>) =>
suggestions.length > 0
? combineLatest(suggestions.map(suggestion => suggestion.visible$))
: of([] as boolean[]),
),
debounceTime(0),
startWith(this.suggestions.map(suggestion => suggestion.visible)),
publishRef(),
);

this.hasVisibleSuggestion$ = this.visibles$.pipe(
debounceTime(0),
map(visible => visible.some(Boolean)),
withLatestFrom(this.directive$$),
map(([hasVisibleSuggestion, directive]) => {
Expand Down
16 changes: 7 additions & 9 deletions stories/autocomplete/disabled.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ import { ChangeDetectionStrategy, Component } from '@angular/core';
</button>
<br />
<br />
<form #form="ngForm">
<aui-tags-input
name="fruit"
[(ngModel)]="value"
[auiAutocomplete]="suggestions"
placeholder="水果"
[disabled]="disabled"
></aui-tags-input>
</form>
<aui-tags-input
name="fruit"
[(value)]="value"
[auiAutocomplete]="suggestions"
placeholder="水果"
[disabled]="disabled"
></aui-tags-input>
<aui-autocomplete #suggestions>
<aui-suggestion value="apple">apple</aui-suggestion>
<aui-suggestion value="banana">banana</aui-suggestion>
Expand Down

0 comments on commit e9eca03

Please sign in to comment.