Describe the bug 馃悰
When using a menuSelect widget, if there is only one option (other than the seeAllOption), this widget should be hidden since selecting that single option is the same as selecting the seeAllOption
To Reproduce 馃攳
Steps to reproduce the behavior:
menuSelect widget that will only have one optionseeAllOptionExpected behavior 馃挱
If there is only one option other than the seeAllOption this widget should be hidden.
Screenshots 馃枼

Thanks for the feedback. We're actually looking for revamping the conditions for the autohideContainer feature.
Is there any timeline for v3.0?
Not at the moment @davist11
馃憤
do you have any suggestions for how to handle this issue with the current version?
The most straightforward and hacky way would be to use the helper, listen to the result event, check if there is only one value returned and hide the container of your menu:
const search = instantsearch(/* config */);
// ...
search.start();
search.helper.on('result', (results) => {
const values = results.getFacetValues('yourMenuFacet');
if(values.length <= 1) hide();
else show();
});
https://community.algolia.com/algoliasearch-helper-js/reference.html#SearchResults#getFacetValues
Awesome, thank you.
For reference for anyone else who needs something like this, I had to update the conditional like so:
if (Array.isArray(values.data) && values.data.length <= 1) {
hide()
} else {
show()
}
Since InstantSearch.js 3, you can use the panel widget like this:
const brandMenuSelect = instantsearch.widgets.panel({
hidden: ({ results }) => results.getFacetValues('brand').data.length <= 1,
})(instantsearch.widgets.menuSelect);
search.addWidget(
brandMenuSelect({
container: '#brand-list',
attribute: 'brand',
})
);
Most helpful comment
Since InstantSearch.js 3, you can use the
panelwidget like this: