Instantsearch.js: Add possibility to clear searchBox value using the clearAllWidget

Created on 20 Mar 2017  路  9Comments  路  Source: algolia/instantsearch.js

For now the clearAll widget only allows to clear facet refinements, but not the search query itself. Would be great to have a way that enables it, either:

  • by having an new option in the widget configuration, and say true|false
  • letting define a hook function that would be called once the user has clicked and in which we could call search.helper.setQuery('').search()
Widgets Needs Investigation

Most helpful comment

We could introduce that as a change for a v2 of instantsearch.js?

All 9 comments

Why not make it the default behavior? I don't remember the rationale behind this choice, but it does not seem to hold imho.

I agree, a clear all should clear everything by default (even if it'd require a minor version change)

Not sure we can make it default without breaking backward compatibility.
That being said, it would be great to be able to clear one, or the other, or both.

We could introduce that as a change for a v2 of instantsearch.js?

I agree with you @bobylito, clearAll as it says should clear everything from state of search. Maybe we can introduce a clearRefinements widget to keep a way to achieve current behaviour?

Man oh man, I've been working all day on trying to set something like this up. I want to give my users to ability to click an "X" button on the search bar and 'clearAll' input text - not just selected facets - but it seems like this is not yet possible.

Hi @WinstonGFX, this will be possible in v2, which is already in beta. Check out the new doc: https://community.algolia.com/instantsearch.js/v2

Done in v2

Done in v2

Here: https://community.algolia.com/instantsearch.js/v2/widgets/clearAll.html#struct-ClearAllWidgetOptions-clearsQuery

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jvreeken picture jvreeken  路  3Comments

anthonyBertrant picture anthonyBertrant  路  3Comments

nicosrugeris picture nicosrugeris  路  3Comments

proudlygeek picture proudlygeek  路  4Comments

object505 picture object505  路  4Comments