appbaseio / appbaseio/reactivesearch

Filters being reset when navigating back/forward

Open
#1,138 8 comments 1 reaction 1 assignee Claimed by @bietkul View on GitHub
bug
Dominant language
JavaScript
Stars
4.9k
Forks
478
PR merge metrics
No merged PRs in 30d

Description

**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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.