meilisearch-js-plugins icon indicating copy to clipboard operation
meilisearch-js-plugins copied to clipboard

keepZeroFacets not keeping facets with 0 matches when using custom search method with search client

Open lyubchev opened this issue 2 years ago • 5 comments

Description

Hello, I am trying to preserve the facets from my RefinementList when I select one, but the ones which are not selected disappear. Let's say we have 3 categories - clothes, shoes, and accessories, clicking on "clothes" would hide shoes and accessories until I unselect clothes I saw in the README that you could provide a keepZeroFacets property to the client since version 0.6.2 I updated my client, set the property to true, and also made sure that my attributes are filterable in the backend. Still, I can't retain the non-chosen categories in the RefinementList

Expected behavior

As the documentation from README states, I expected that after a refinement, facets/filters with 0 matches would still appear in the list

Current behavior

As described, currently when refinement finishes, my RefinementList the items prop contains only the currentRefinement (for example the selected category - clothes)

Steps to reproduce

Thankfully I managed to reproduce this in a code sandbox here

Environment

  • OS: EndeavourOS
  • Browser: Chrome Version 102.0.5005.115 (Official Build) (64-bit)
  • Meilisearch version: 0.26.1
  • instant-meilisearch version: 0.6.2

lyubchev avatar Jun 23 '22 18:06 lyubchev

We have the same problem, the none selected facets disappear when one is selected in our refinementList. Is there any fix yet?

Sidran83 avatar Jun 28 '22 07:06 Sidran83

Hey! I think this might be linked to #775 but I'm not sure! I will investigate this issue after the pre-release of Meilisearch v0.28.0 ( after 11 july)

bidoubiwa avatar Jun 28 '22 11:06 bidoubiwa

in our case we don't use placeholdersearch: false as mentioned in #775 We have operator: "or" and keepZeroFacets: true inside our refinementList So maybe it's the operator that's not working?

Sidran83 avatar Jun 29 '22 09:06 Sidran83

Are you using react by any chance?

bidoubiwa avatar Jun 29 '22 10:06 bidoubiwa

I am using react and no matter what I try I can't get 0 facets.

Are you using react by any chance?

ar-siddiqui avatar Aug 11 '22 18:08 ar-siddiqui

Thanks @ar-siddiqui there seems to be an issue with how React understands the conditionals of facets.

bidoubiwa avatar Aug 22 '22 09:08 bidoubiwa

Hey @impzero could you try your bug again with the latest release (v0.8.2) ?

bidoubiwa avatar Sep 01 '22 15:09 bidoubiwa

Should be fixed! If it is not, please tell me and re open :)

bidoubiwa avatar Sep 27 '22 15:09 bidoubiwa