From 5f4959d3ed0bc22d29570f64912ee117d2a1201a Mon Sep 17 00:00:00 2001 From: Abram Booth Date: Fri, 13 Oct 2023 14:02:45 -0400 Subject: [PATCH] fix: skip showing "top" values for creator facet --- .../search-page/filter-facet/component.ts | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/lib/osf-components/addon/components/search-page/filter-facet/component.ts b/lib/osf-components/addon/components/search-page/filter-facet/component.ts index 3367e679bc3..18a0070c4fe 100644 --- a/lib/osf-components/addon/components/search-page/filter-facet/component.ts +++ b/lib/osf-components/addon/components/search-page/filter-facet/component.ts @@ -48,12 +48,21 @@ export default class FilterFacet extends Component { @tracked hasMoreValueOptions = false; @tracked nextPageCursor = ''; + get shouldShowTopValues() { + const { args: { property: { propertyPathKey } } } = this; + return propertyPathKey !== 'creator'; + } + @action toggleFacet() { - if (this.filterableValues.length === 0 && !taskFor(this.fetchFacetValues).lastComplete) { - taskFor(this.fetchFacetValues).perform(); + if (this.shouldShowTopValues) { + if (this.filterableValues.length === 0 && !taskFor(this.fetchFacetValues).lastComplete) { + taskFor(this.fetchFacetValues).perform(); + } + this.collapsed = !this.collapsed; + } else { + this.openSeeMoreModal(); } - this.collapsed = !this.collapsed; } @action @@ -105,8 +114,14 @@ export default class FilterFacet extends Component { @waitFor async fetchFacetValues() { const { cardSearchText, cardSearchFilter, property } = this.args; - const { page, sort, filterString } = this; - + const { page, sort, filterString, shouldShowTopValues } = this; + if (!shouldShowTopValues && !filterString.trim()) { + this.filterableValues = []; + this.modalValueOptions = []; + this.hasMoreValueOptions = false; + this.nextPageCursor = ''; + return; // skip fetching + } const valueSearch = await this.store.queryRecord('index-value-search', { cardSearchText, cardSearchFilter,