algolia / react-instantsearch

⚡️ Lightning-fast search for React and React Native applications, by Algolia.
https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/react/
MIT License
1.97k stars 386 forks source link

Refinements applied in modal are cleared on close, virtual widget doesn't appear to be working? #1776

Closed rtman closed 5 years ago

rtman commented 5 years ago

Hi,

So for my web app I want to put our refinements in a modal. I've followed the guide for doing this and still the refinements applied in the modal are cleared when the modal is closed. Maybe I've made a mistake or am using the Virtual Widget incorrectly??

I also notice a significant slowdown when passing searchstate and onSearchStateChanged between the two InstantSearch instances. If I comment out those two props on the 1st instance the slowdown disappears. This effect isn't as noticeable in the codesandbox but in my actual app the slowdown is severe.

Here is my codesandbox illustrating the issue.

https://codesandbox.io/s/3y7kw953ym

samouss commented 5 years ago

The state of the RefinementList inside the modal is not persisted because the onSearchStateChange callback only apply the current state. Inside our React Native example we do merge the previous and the current state. Here is your example updated.

rtman commented 5 years ago

Ah ok, I was following another guide from the react-instantsearch docs on your site which doesn't show previous and current state merging. Can you guys update the docs ?

samouss commented 5 years ago

We are in the process of re-writing the full documentation, this issue will be fixed at that time. Thanks for spotting the issue though!