franciscan-react icon indicating copy to clipboard operation
franciscan-react copied to clipboard

Add search filters to browser history

Open cr101 opened this issue 6 years ago • 5 comments

It would be a good idea to add the ticked checkboxes to the browser history so that if a user sends the search page url to a friend then that person will not see a blank page.

cr101 avatar Mar 09 '18 08:03 cr101

Maybe it's possible to change the URL's querystring based on the checkboxes ticked (eg. franciscan.edu/search?departments=true&faculty=true)

This https://github.com/zeit/next.js#shallow-routing has more information about replacing the URL silently.

NickyMeuleman avatar Mar 09 '18 14:03 NickyMeuleman

This is a good idea. I don't think it is necessary before launch, but should be high on the list of things to do..

JesseRWeigel avatar Mar 09 '18 15:03 JesseRWeigel

url-search-params will help with checking if a particular URL search parameter exists.

Does replacing the URL using Shallow Routing create browser history every time the url is changed? If not, the history JS library will be handy but it would make more sense to use NextJS Shallow Routing to keep the JS file size small

cr101 avatar Mar 12 '18 23:03 cr101

The query parameters in the URL are available on the object that gets passed into getInitialProps

https://github.com/zeit/next.js/#fetching-data-and-component-lifecycle A bit down, under the section that lists what's in the context object.

The state of true/false for the checkboxes can probably be set based on the query parameters on the initial load (so, inside getInitialProps). If that's acceptable, I know it's a no-no to sync state and props in some lifecycle hooks, it seems like it would be ok here.

NickyMeuleman avatar Mar 13 '18 14:03 NickyMeuleman

This has been partially implemented. I think we just need to change the url when searching from the search page without actually navigating anywhere. Very similar to what was done with the app bar and side drawer search inputs.

JesseRWeigel avatar Aug 17 '18 20:08 JesseRWeigel