reactivesearch icon indicating copy to clipboard operation
reactivesearch copied to clipboard

Filters being reset when navigating back/forward

Open ishaanjain opened this issue 6 years ago • 8 comments

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

ishaanjain avatar Sep 05 '19 18:09 ishaanjain

Any update on this?

thusitha458 avatar Feb 26 '20 04:02 thusitha458

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.

ghost avatar Mar 18 '20 02:03 ghost

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.

MichaelBurb avatar May 16 '20 18:05 MichaelBurb

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.

stale[bot] avatar Nov 13 '20 01:11 stale[bot]

Agree that this is a fairly significant issue.

davidkong0987 avatar Nov 16 '20 03:11 davidkong0987

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.

davidkong0987 avatar Dec 15 '20 12:12 davidkong0987

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

bietkul avatar Dec 21 '20 10:12 bietkul

This one is killing me, any chance we can just stop the reloading if you open a new tab?

alorr10 avatar Apr 28 '21 00:04 alorr10