algolia / vue-instantsearch

πŸ‘€ Algolia components for building search UIs with Vue.js

Home Page:https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/vue

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

First predefined facet-filter will be overwritten by ais-refinement-list facets

th1nkgr33n opened this issue Β· comments

Bug 🐞

What is the current behavior?

If setup a pre-defined facetFilter inside ais-configure like

  <ais-configure 
    :facet-filters.camel="[
      [
        'brand:Amazon',
        'brand:Google',
      ],
    ]"
  />

the first filter will be overwritten if I click on a facet (e.g. Streaming Media Player). And more than 6 of the expected items are returns. Doesn't matter if I setup the refinement List with operator="and" or operator="or".
You could also inspect the payload inside the call to algolia and you will see that the facetFilters-Array will be manipulated in loosing the first element.

We fixed this issue by adding a blank placeholder for each facet we want to refine.
In example of the sandbox I added one blank entry to array in which the refinementList could add his stuff.

        <ais-configure 
          :facet-filters.camel="[
            '', // first filter will be overwritten from the refinementlist?? WHY?
            [
              'brand:Amazon',
              'brand:Google',
            ],
          ]"
        />

Then the results will be really just 6.

Make a sandbox with the current behavior

https://codesandbox.io/s/vigorous-hugle-3dhtp?file=/src/App.vue

What is the expected behavior?

The search results should only show 6 results and not more!

Does this happen only in specific situations?

Not really... see Sandbox. I just added the facet-filters and switch the refinementlist attribute to categories.

What is the proposed solution?

The facetFilters from the refinementList should be added and not overwrite the pre defined facetFilters from ais-configure.

What is the version you are using?

Latest 4.2.0 (See sandbox package.json)

facetFilters is a "controlled" parameter, and isn't meant for static parameters, but for other widgets to set. If you want to set the static filter you can either still set that via filters in configure: https://codesandbox.io/s/nervous-meadow-orzbq?file=/src/App.vue or via a secured api key: https://www.algolia.com/doc/api-reference/api-methods/generate-secured-api-key/#method-param-filters

Oh no.. sorry, I miss understood the docs. Thanks for making this clear! I switched it and it worked.
Thanks!

No problem, this indeed could do with some more clarification in the documentation

@Haroenv Just making sure, in your comment you say to set the static filter using facets in Configure. Did you mean to say filters in Configure? That's what the codesandbox seems to be doing

Yes, sorry, that's meant to say "filters", not facets. Thanks for the clarification @zakjholt