react-instantsearch icon indicating copy to clipboard operation
react-instantsearch copied to clipboard

Refresh wipes out current search

Open unoscar opened this issue 4 years ago • 2 comments

Describe the bug 🐛

When even I use refresh on my <InstantSearch> component, the whole search resets. I'd hope that the current search page and refinements are kept but everything resets

To Reproduce 🔍

Currently I have the refresh value in the useState hook value and when I update something in algolia I wait for the operation to finish and then use this function to trigger the refresh

const pushRefresh = () => { setRefresh(true); setTimeout(() => { setRefresh(false); }, 1000); };

Expected behavior 💭

That the search keeps the current page and refinement parameters

Environment:

Using Next.js

unoscar avatar Apr 08 '21 17:04 unoscar

Can you create what you have so far in a sandbox environment? We have a template available for that purpose here. Thanks!

Haroenv avatar Apr 09 '21 08:04 Haroenv

Hi @Haroenv thanks for the follow up and thank you for the sandbox link, I was able to start narrowing my use case using the sandbox. It seems that what is making this behavior is my custom connectPagination component. I have created a custom update to the sandbox you gave me with just that component as an extra addition and it is giving me the same result as in my site.

Here is the link https://codesandbox.io/s/dreamy-chaum-kpers?file=/src/App.js

Here are the steps on how to replicate:

  1. change a page in the pagination at the bottom
  2. pick any refinement
  3. click the Item Action button [this button just has a promise but I normally do actions to the database here]

After this the search resets completely

In the meantime I will use the default pagination and just style it in my site. But I don't see anything I can notice about why this custom connector will make the whole search reset on refresh.

let me know if there is any other information you may need. Thank you very much.

unoscar avatar Apr 09 '21 13:04 unoscar