Instantsearch.js: [currentRefinements] clearsQuery

Created on 15 May 2017  路  12Comments  路  Source: algolia/instantsearch.js

Current behaviour

When clearsQuery is true, the button for clearing the refinements also clears the query.

However if there are no other refinements, the button doesn't appear. Also the query is not considered a current refinement, therefore even though it would cleared by the button it doesn't appear.

Proposed fix

Make the clearsQuery trigger the following changes:

  • the clear all button clears the query too (and is visible when only the query is set)
  • the query appears as a refinement
Bug

Most helpful comment

@vvo
What I propose is the following: when you choose to activate clearsQuery, we should display the query. On the other hand, if clearsQuery is false we don't display the query. This brings consistency to the feature: what you can see is what gets cleared.

All 12 comments

cc @iam4x @mthuret @vvo @rayrutjes

What about making it show up when there鈥檚 a query, but not showing that in the refinements, it would look a bit weird.

I'm good with your proposed fix 馃憤

I am fine with your proposal @bobylito. And if the user want to hide the query on display, what would he have to do?

And if the user want to hide the query on display, what would he have to do?

We have a white list mechanism which could be used. However it doesn't fit the usage of refinements that are not attribute based (query or any query parameters) 馃挃 . Maybe we could extend the range of possibilities here?

Ok that's too much of an edge case. Let's implement the clearsQuery that will only make the clear all button clear the query without any rendering of the query in the current refinements.

Hey guys, customer here... good discussion. Would including the search query as a refinement really be that weird? Consider the attached screenshot - I think this would be handy.
alg-search-in-refinements

And if the user want to hide the query on display, what would he have to do?

Actually after thinking about it, if you've enabled clearsQuery isn't it reasonnable to have the whole package (the button is enabled when the query is not empty and the query appears in the refinements)? @vvo

I did not quite get what you proposed. If the question is is it ok to have the query appears in refinements then I would say yes, as @fabregas4 proposed and showed us.

With that said, let's see if anyone wants to hide the query afterwards and deal with that once it shows as a need/issue.

@vvo
What I propose is the following: when you choose to activate clearsQuery, we should display the query. On the other hand, if clearsQuery is false we don't display the query. This brings consistency to the feature: what you can see is what gets cleared.

Very good solution

Fixed via #2414 and released in 2.2.0

Was this page helpful?
0 / 5 - 0 ratings