Skip to content

Commit

Permalink
Hide search text field when number of facet values is less than the m…
Browse files Browse the repository at this point in the history
…aximum (#3061)

Hide search text field in the filter section if the number of facet values does not exceed the maximum number of facet values shown.
  • Loading branch information
VictorHugoDuranS authored May 22, 2024
1 parent 088e56f commit 975e9fd
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@
(submitSuggestion)="onSubmit($event)"
(clickSuggestion)="onClick($event)"
(findSuggestions)="findSuggestions($event)"
*ngIf="!(isAvailableForShowSearchText | async)"
ngDefaultControl></ds-filter-input-suggestions>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,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
*/
Expand Down Expand Up @@ -297,6 +301,8 @@ export class SearchFacetFilterComponent implements OnInit, OnDestroy {
getFirstSucceededRemoteData(),
tap((rd: RemoteData<FacetValues>) => {
this.isLastPage$.next(hasNoValue(rd?.payload?.next));
const hasLimitFacets = rd?.payload?.page.length < rd?.payload?.facetLimit;
this.isAvailableForShowSearchText.next(hasLimitFacets && hasNoValue(rd?.payload?.next));
}),
map((rd: RemoteData<FacetValues>) => ({
values: observableOf(rd),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
(submitSuggestion)="onSubmit($event)"
(clickSuggestion)="onClick($event)"
(findSuggestions)="findSuggestions($event)"
*ngIf="!(isAvailableForShowSearchText | async)"
ngDefaultControl
></ds-filter-input-suggestions>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@
(submitSuggestion)="onSubmit($event)"
(clickSuggestion)="onClick($event)"
(findSuggestions)="findSuggestions($event)"
*ngIf="!(isAvailableForShowSearchText | async)"
ngDefaultControl></ds-filter-input-suggestions>
</div>

0 comments on commit 975e9fd

Please sign in to comment.