The Facets must be collapsed by default on page load

Hi Support,

We would like to request a feature in your upcoming version where the facets in the left sidebar must be collapsed by default when page loads. This will prevent the user to scroll down a page when a lot of facet filters are there in the left sidebar. Also, it gives flexibility to view all the filters at once during above the page fold.

We can do it using below changes i.e

diff --git a/view/frontend/web/instantsearch.js b/view/frontend/web/instantsearch.js
index 624e03d…e67e360 100644
— a/view/frontend/web/instantsearch.js
+++ b/view/frontend/web/instantsearch.js

@@ -448,6 +448,9 @@ requirejs([‘algoliaBundle’, ‘Magento_Catalog/js/price-utils’], function (algolia
/** Add all facet widgets to instantsearch object **/

window.getFacetWidget = function (facet, templates) {
 			var panelOptions = {
                             collapsed: ({ state }) => {
                             return true;
                         },

and then, apply css like given below:


.ais-Panel--collapsed .ais-Panel-body {
    display: none;
}

Hey @prince!

This is definitely worth a discussion on figuring out the optimal defaults and how to add easy ways to override the defaults of the facet widget.

The best place to raise this will probably be as an Issue on the GitHub repository for InstantSearch. That’s where the engineers and product team will see it and be able to dive deeper into it.