AutoHideContainer and panel widget replacement problem


Panel widget has been designed to replace autoHideContainer on refinementList widget.
We now have to use it to show or not show the header of the widget.

On doc, it was explained that we have to use this :

  hidden(options) {
    return options.results.nbHits === 0;

But the solution is not working for me.
options.results.nbHits don’t care about the refinement result… it’s the global result !

AutoHideContainer was designed to hide the container based on the refinement.
For example :

  • My search could have 10 hits of offers.
  • I have a refinement based on the discounts applied to each offer. (for example Promo, Solde, Flash)

Now imagine we don’t have discounts applied on this 10 hits, so my container don’t have to show up but with your solution the container still show up and the header too (although there is no refinement).

Since Algolia depreciated autoHideContainer, i think it’s over complicated things… i have have to replace one line of code by a block of code. I have 6 refinements list, it’s a pain in the ass to add one panel for each refinement.

How can i modify the hidden function to apply hidden based on refinement ?

Thanks for your help

The example there is generic, you can also read if there are facet results there like this:

const autoHideRefinementList = instantsearch.widgets.panel({
  hidden({ results }) {
    return results.getFacetValues('brand').length === 0;

Thank you very much @haroen !