refine icon indicating copy to clipboard operation
refine copied to clipboard

[BUG] Refreshing a page with Ant Design's useTable's search usage doesn't bring back the value

Open linkscope opened this issue 10 months ago • 5 comments

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

  1. Follow Ant Design's useTable's search to complete the example.
  2. Enable syncWithLocation: true.
  3. Unable to find url parameter in searchFormProps.initialValues.

Expected behavior

Normal echoing of parameters from the url to the search form

Packages

Additional Context

No response

linkscope avatar Mar 29 '24 08:03 linkscope

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.

BatuhanW avatar Mar 29 '24 08:03 BatuhanW

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:

  1. Disable Search from participating in syncWithLocal, so that although the state is cleared on each refresh, all parameters are also cleared on request.
  2. Allow syncWithLocal but need to be able to show parameters back in Search when refreshing, can't show parameters back at the moment.

linkscope avatar Mar 29 '24 11:03 linkscope

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

BatuhanW avatar Apr 03 '24 09:04 BatuhanW

Hi @BatuhanW. Have this issue resolved? I also have the same problems with video that you attached.

CapiZerbino avatar May 02 '24 13:05 CapiZerbino

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 🙏

aliemir avatar May 02 '24 13:05 aliemir