refine
refine copied to clipboard
[BUG] Refreshing a page with Ant Design's useTable's search usage doesn't bring back the value
Describe the bug
Hello,
When following the example from the official documentation Ant Design's useTable's search, I found that when syncWithLocation: true
, the url's parameters are not in searchFormProps.initialValues
and the onSearch
hook is not triggered on the first render, but the parameters are brought in when requesting the API, is this a bug? If it is not an error, please let me know the solution.
Thanks, team
Steps To Reproduce
- Follow Ant Design's useTable's search to complete the example.
- Enable
syncWithLocation: true
. - Unable to find url parameter in
searchFormProps.initialValues
.
Expected behavior
Normal echoing of parameters from the url to the search form
Packages
- @renfinedev/[email protected]
Additional Context
No response
Hey @linkscope can you clarify what do you mean here?
but the parameters are brought in when requesting the API
Search isn't expected to be triggered on the first render. Only after user searches something.
Hello, @BatuhanW but I did find parameters being carried in the request API, and I'm guessing it might be because Search is still essentially a Filter, which can also be seen as a filter field in the url parameter, and I'm having these two thoughts right now:
- Disable Search from participating in
syncWithLocal
, so that although the state is cleared on each refresh, all parameters are also cleared on request. - Allow
syncWithLocal
but need to be able to show parameters back in Search when refreshing, can't show parameters back at the moment.
Hey @linkscope thanks for the clarification! I see the point now. Adding video to give context. We'll discuss it and get back to you.
https://github.com/refinedev/refine/assets/16444991/b0938920-e380-4901-8a3a-6de0f2f3b36f
Hi @BatuhanW. Have this issue resolved? I also have the same problems with video that you attached.
Hey @linkscope and @CapiZerbino, this issue is related with our CRM example app. Default value for the search input is missing, even though the filter persists with syncWithLocation
, the search value doesn't get reflected in the input. We can easily fix this issue with using the getDefaultFilter
helper from @refinedev/core
.
If anyone is interested on working this one, we'd be happy to see your contributions 🙏