I am trying to build a simple search functionality for a resource using filters. The search works fine using <SearchInput> but it reacts to every keypress. Such unnecessary searches (where the user is typing and is not done with the query) can cause performance degradation at the back end
It should be possible to trigger search explicitly (ie a search Button) that does the same thing that searchInput onChange is currently doing.
As we can't support all types of interactions, we chose not to support that it in the core. However, you can write a custom Filter component to support this behavior.
As a side note, the current Filter component doesn't send one request every keystroke: it uses a debounce filter.
I also have a need for this. @hatim-oss Have you found any workaround yet? @fzaninotto Does that mean reimplementing the FilterForm as well?
I find that without a possibility to do the search only when you press enter is annoying. In our case, we have very huge dataset of millions of records and we don't want to show the list with any items until somebody provides the search keyword and presses enter. Now, every time one is typing something, it'll make a request to server and it could be very costly this way for a huge dataset. I tried to implement a custom Filter that supports search on enter only but it looks like it's very hackish (I had to copy & paste code from the core and modify accordingly). It'd be very beneficial if the framework can support this. Otherwise, I think it won't scale. @fzaninotto What do you think?
@ngocketit I disagree. React-admin provides one way to do filtering and allows you to pass your own Filter component if the default doesn't fit you. We can't handle all use cases (and we don't want to, because we have limited resources to spend in this project).
But I'm sure your use case is common enough that you can release your custom filter as a standalone package and have your own set of contributors. I encourage you to do it!
@fzaninotto I think the default filter is already very good that we don't want to drop it completely, but only add the possibility to do the filter only on enter. However, I think it's pretty weird to have a separate project just for adding that possibility on the already existing filter, not to mention that I'll need to keep it in sync with any potential changes upstream.
@fzaninotto or anyone now we have any idea how set a apply button on filters so filter query get's call only when press the apply button
Most helpful comment
I find that without a possibility to do the search only when you press enter is annoying. In our case, we have very huge dataset of millions of records and we don't want to show the list with any items until somebody provides the search keyword and presses enter. Now, every time one is typing something, it'll make a request to server and it could be very costly this way for a huge dataset. I tried to implement a custom
Filterthat supports search on enter only but it looks like it's very hackish (I had to copy & paste code from the core and modify accordingly). It'd be very beneficial if the framework can support this. Otherwise, I think it won't scale. @fzaninotto What do you think?