Fix - hide search text field in the filter section if the number of facet values does not exceed the maximum number of facet values shown

This commit is contained in:
Victor Hugo Duran Santiago
2024-05-16 18:45:41 -06:00
committed by Tim Donohue
parent ebf9469846
commit 906b2f5917
2 changed files with 7 additions and 0 deletions

View File

@@ -104,6 +104,10 @@ export class SearchFacetFilterComponent implements OnInit, OnDestroy {
*/
isLastPage$: BehaviorSubject<boolean> = new BehaviorSubject(false);
/**
* Emits true if show the search text
*/
isAvailableForShowSearchText: BehaviorSubject<boolean> = new BehaviorSubject(false);
/**
* The value of the input field that is used to query for possible values for this filter
*/
@@ -289,6 +293,8 @@ export class SearchFacetFilterComponent implements OnInit, OnDestroy {
getFirstSucceededRemoteDataPayload(),
tap((facetValues: FacetValues) => {
this.isLastPage$.next(hasNoValue(facetValues?.next));
const hasLimitFacets = facetValues?.page.length < facetValues?.facetLimit;
this.isAvailableForShowSearchText.next(hasLimitFacets && hasNoValue(facetValues?.next));
}),
)),
map((newFacetValues: FacetValues) => {

View File

@@ -26,5 +26,6 @@
(submitSuggestion)="onSubmit($event)"
(clickSuggestion)="onClick($event)"
(findSuggestions)="findSuggestions($event)"
*ngIf="!(isAvailableForShowSearchText | async)"
ngDefaultControl></ds-filter-input-suggestions>
</div>