@sledge-app/react-instant-search 1.0.96 → 1.0.97

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5354,19 +5354,23 @@ const SearchResultWidget = (props) => {
5354
5354
  queries: getTabs.map((tab) => {
5355
5355
  const { index } = tab;
5356
5356
  let isSetFilter = false;
5357
- let getFacets = !isSetFilter ? filters == null ? void 0 : filters.map((filter) => {
5358
- const { collections, items } = filter;
5359
- const newItems = items == null ? void 0 : items.map(({ value, ...otherItem }) => (otherItem == null ? void 0 : otherItem.display) === "tree" ? HIERARCHICAL_FACET_OBJECT_ALIASES[value] : value);
5360
- if (collectionId && (collections == null ? void 0 : collections.includes(Number(collectionId)))) {
5361
- isSetFilter = true;
5362
- return newItems;
5363
- } else {
5364
- if (collections == null ? void 0 : collections.includes("all")) {
5357
+ let getFacets = [];
5358
+ if (!isSetFilter)
5359
+ filters == null ? void 0 : filters.map((filter) => {
5360
+ const { active, collections, items } = filter;
5361
+ if (!active)
5362
+ return;
5363
+ const newItems = items == null ? void 0 : items.map(({ value, ...otherItem }) => (otherItem == null ? void 0 : otherItem.display) === "tree" ? HIERARCHICAL_FACET_OBJECT_ALIASES[value] : value);
5364
+ if (collectionId && (collections == null ? void 0 : collections.includes(String(collectionId)))) {
5365
5365
  isSetFilter = true;
5366
- return newItems;
5366
+ getFacets = newItems;
5367
+ } else {
5368
+ if (collections == null ? void 0 : collections.includes("all")) {
5369
+ isSetFilter = true;
5370
+ getFacets = newItems;
5371
+ }
5367
5372
  }
5368
- }
5369
- }) : [];
5373
+ });
5370
5374
  let isProductIndex = index.includes(index_product);
5371
5375
  let isHasProductFacets = isProductIndex && getFacets.length;
5372
5376
  let additionalFilter = [];
@@ -5377,12 +5381,12 @@ const SearchResultWidget = (props) => {
5377
5381
  if (collectionId)
5378
5382
  additionalFilter.push(`'collections.id' = '${collectionId}'`);
5379
5383
  if (isHasProductFacets)
5380
- setFacets(getFacets[0]);
5384
+ setFacets(getFacets);
5381
5385
  return {
5382
5386
  indexUid: index,
5383
5387
  q: keyword || "",
5384
5388
  hitsPerPage: 1,
5385
- facets: isHasProductFacets ? getFacets[0] : [],
5389
+ facets: isHasProductFacets ? getFacets : [],
5386
5390
  filter: isProductIndex ? [...new Set(additionalFilter.concat(DEFAULT_QUERY_PRODUCT_MEILISEARCH))].join(" AND ") : "",
5387
5391
  attributesToRetrieve: [],
5388
5392
  limit: 0,