Clear Event on Category Filter Component

I’d like to suggest an event on the clear icon for the Category Filter (something like ‘filterCleared’.

For instance: I want to be able to click on the clear icon and through this event I know I can call my API again to reset the data state to the previous one without any filter.

This way we can clear not only the selected categories in the UI but also decide when to call the API and also clear the state.

You can already listen to the filterChanged event. If it returns an empty filter state (i.e. tokens: [], categories: []) it is equivalent to the requested event.
I do agree that a clear event could be useful nevertheless.

OK, but isn’t it its starting state as well?

So at some point, after using the filter for the first time, I have to listen to when the state becomes ‘tokens:, categories: ’ again?

if the filter has changed to this empty state I presumably can make sure the filter was cleared?

Yes, I think it’d better to simply emit the click event from the clear icon.

Created a PR for it.

1 Like