Filters being reset when navigating back/forward
Affected Projects: React
Library Version: 3.0.0-rc.22
Description I'm using several ReactiveSearch components in my single page application. When the user clicks on a react-router Link and goes to a different virtual page, then any ReactiveSearch component that remained mounted from the first "page" to the second continues to work correctly. But when the user navigates between "pages" using the browser's back button, then the ReactiveSearch components have their inner state reset (this state specifies which filters have been selected). Which is weird, because these components were never unmounted & remounted, they remained mounted during the "page" transition. This seems to be a bug in ReactiveSearch.
To Reproduce I reproduced the issue here: https://codesandbox.io/s/selectedfilters-yci87 Type any word into the search box. That word act as a filter (aka BookSensor). Now click the Root/Test links as many times as you want. The Home component does not remount (I used a console.log statement in the Home component's componentDidMount lifecycle function to check this). So, as you would expect, the filter does not go away. But now click the back button. The Home component still does not remount (as expected) BUT the filter is reset.
Expected behavior The expected behavior is for the filters to remain after the user hits the back/forward button. It should be similar to how the filters remain after the user clicks on a react-router link. In other words, any navigation performed by the user that does not actually remount the ReactiveSearch components should not result in a reset of ReactiveSearch's state.
Desktop:
- OS: MacOS
- Browser: Chrome
- Version 75
Any update on this?
I am experiencing the same issue with the range slider component.
https://codesandbox.io/s/selectedfilters-yj01b
Additionally it seems to be ignoring the defaultValue prop.
Has anyone found a fix or workaround for this issue yet? For me, I was only able to avoid this problem by disabling URLParams on the ReactiveList component, which is obviously not ideal.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Agree that this is a fairly significant issue.
Generally, I've noticed that using controlled components is much more reliable than not using controlled components, and often avoids things like this. After switching to a controlled components, the filters no longer reset.
If you use a new ReactiveBase provider in each route then it'll reset the filters on page change.
I found that even if we use routers under a single ReactiveBase provider then also filters are getting reset that should not be expected behavior.
https://codesandbox.io/s/selectedfilters-forked-3v0po?file=/src/index.js
This one is killing me, any chance we can just stop the reloading if you open a new tab?