Gravatar for

Question by EVillarino, Nov 5, 2018 8:40 PM

Hiding coveoresultlist until facets are selected

I have a requirement to hide the coveoresultlist component until one or more facet values are selected. Any suggestions?

Gravatar for

Comment by François Lachance-Guillemette, Nov 5, 2018 8:47 PM

Do you have a very specific use case where this requirement makes sense? I can't really see a use case where this will result in a better experience...

I would recommend vouching against this requirement because it will drastically affect relevance, which is Coveo's main feature.

What if the user don't want any filter, but just enter a keyword in the search box? Isn't it strange to not propose anything to the end-user when they don't click on any filter?

2 Replies
Gravatar for

Answer by Jean-François L'Heureux, Nov 6, 2018 10:42 AM

There is no option in the Coveo JavaScript Search Framework to achieve what you want.

I recommend you to hide the results list with CSS by default, then write an event handler for the `doneBuildingQuery` event that will display the results list (by changing the CSS classes, or adding inline styles) only when one of your facet has selected values:

Do not forget to revert your CSS changes when the user unselect its facet values.

Gravatar for

Comment by EVillarino, Nov 6, 2018 4:26 PM

This worked for me. Thank you.

Gravatar for

Answer by François Lachance-Guillemette, Nov 5, 2018 8:59 PM

I would instead recommend to not execute the first query using the `autoTriggerQuery` attribute of the `SearchInterface` component as seen here.

This will make it so the first query will not be automatically executed. Once any change is done, it will execute a query like usual.

I think this will give you the behavior that you need.

Gravatar for

Comment by Jean-François L'Heureux, Nov 6, 2018 10:37 AM

This will not work because facet values are filled by a query response. Not executing the first query will not render the facets.

Ask a question