-
Notifications
You must be signed in to change notification settings - Fork 529
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question] Clear All an also the query #1936
Comments
Hi @Kikobeats, Having a button that clear both the query and the refinements is something that we thought about including in our default widgets set. Nonetheless, you can already achieve it like this: const ClearQuery = ({refine}) => {
const onClick = ev => {
refine('');
ev.stopPropagation();
};
return <div onClick={onClick}><ConnectedClearAllRefinements/></div>;
};
const ClearAllRefinements = ({refine, items}) => {
const onClick = () => refine(items);
return <button onClick={onClick}>ClearAll</button>;
};
const ClearQueryAndRefinements = connectSearchBox(ClearQuery);
const ConnectedClearAllRefinements = connectCurrentRefinements(ClearAllRefinements); and use it like: <ClearQueryAndRefinements /> |
Thanks! The code is a little tricky but it works 😄 |
I tested it inside our storybook and it worked. Any chance you have more information? Did you try to debug calls? Does both |
I copy paste your code and doesn't work, but maybe I'm doing something bad. The implementation is here: https://github.com/windtoday/windtoday-marketplace/blob/master/src/app/Logo/index.js And using it: https://github.com/windtoday/windtoday-marketplace/blob/master/src/app/AppBar/index.js#L30 🤔 |
The onClick for the searchBox should be on an element wrapping the |
So here's an update of why it's working on my side and not on yours: it's working only if you are using React InstantSearch in an uncontrolled mode. Because you're using the I keep you updated about the development of a solution for this use case. |
Thanks for the reply and your effor, is awesome how algolia dev team interacts with the community! 🥇 |
Finally I implement that using windtoday/windtoday-app@59f6d72#commitcomment-20978203 I'm using it with This means, when the user type something at Even "it works", I detected that I didn't write this before becase I thought that is a little bug and will be fixed soon but I decide comment now for know if I'm still doing something wrong or wat 😢 Looks like |
Hi @Kikobeats, The Here's a working example: when you use the searchbox, it display the content on an extra-div: <InstantSearch>
<SearchBox/>
<CustomClearAll clearsQuery/>
</InstantSearch>
const CustomClearAll = connectCurrentRefinements(({query}) => <div>{query}</div>); |
oh thanks for the tip, now is working 🎉 |
Is there a solution for this yet? I am using Thanks, Chris |
@cmarabate Did you check out the |
Yes, that is what I am using to get it to clear the params from the URL. It DOES clear the search value from the params but it It does NOT clear the value entered in the search box. So if a user wanted to clear all their selected filters and clear what they typed into the searchbox, they would need to click the button to clear all the filters and queries and then they would still need to manually remove what they typed into the searchbox themselves. |
Adding a note here woudln't hurt I think. |
That's indeed a good place to add a note about clearsQuery, does this sound good?
Or should the note rather be on |
I'm trying to create a button for reset the current search query and current refinement selected.
Like
<ClearAll />
but also for clear the query.In the
<Searchbox />
I did that withrefine('')
. I see that<ClearAll />
have a different refine behavior.Could be possible do the same actions? any tip?
The text was updated successfully, but these errors were encountered: