openskope / skope-interface

The new SKOPE web portal interface.
https://www.openskope.org
4 stars 2 forks source link

Preserve search state when transitioning between search page and workspace page. #139

Closed Zodiase closed 6 years ago

Zodiase commented 6 years ago

The idea is to pass the search query (basically everything in the search string on Search Page) to other pages as a query parameter, then other pages can use this value to go back to the specific state of the search page.

This is limited to how much of the state is preserved in the url, but is a more generic solution since it works across page redirections.

Zodiase commented 6 years ago

Simply reading location.search in search result item component doesn't work since they won't get an update to re-render when location is changed.

This means the props passed to the search result item component need to react to search state changes or simply location changes.

Passing FlowRouter queryParams all the way into the components doesn't work since FlowRouter doesn't pickup location changes made by SearchKit. Also the component that renders all the result items, <Hits>, doesn't pass extra props to children. The search result item components have to get the info from Redux state.

Also there is no hook for when SearchKit updates location.

Maybe SearchKit can be patched so it goes through FlowRouter to update the location. This would be ideal.

The current workaround is to read location info whenever SearchKit query returns. It looks like the location is updated in-between SearchKit sending a request and receiving the response. When the value of location is read, save it into global Redux state, then read it in the search result item components.

Conclusions

Zodiase commented 6 years ago

Trying to mock a history interface for FlowRouter.