auspice icon indicating copy to clipboard operation
auspice copied to clipboard

[Feature request] Allow browser back button to reverse state changes

Open corneliusroemer opened this issue 2 years ago • 4 comments

@trvb wrote in #1348:

I'd think the best solution here would be to properly work with the browser back/forward buttons and have this be a feature for generic app state. Ie you change state of Auspice to zoom tree, or filter or whatever and can easily get back to previous state by clicking back button. I think this would be much more intuitive than trying to add a universal back button to the app somewhere.

I think this is a great idea that would make navigating around Auspice even more fun and less frustrating when you're zooming around. @joverlee521 suggested I open a new issue to keep track of this feature request.

corneliusroemer avatar Sep 16 '21 19:09 corneliusroemer

This is indeed possible, and actually implemented for some parts of auspice (e.g. change datasets). The code is here so it would be a matter of updating the relevant (redux) actions to set pushState: true. This should be on a case-by-case basis - e.g. if you slide the date slider, it'll result in many actions dispatched, and I don't think we want all of those in history.

jameshadfield avatar Sep 17 '21 00:09 jameshadfield

I'd like to reiterate my interest in this feature, been browsing a lot of trees lately and something in between 5 times zooming out of a branch and reset zoom and clicking into a branch is sorely missing!

corneliusroemer avatar Oct 31 '21 23:10 corneliusroemer

I've implemented something along these lines in PR https://github.com/nextstrain/auspice/pull/1403. I'll revisit this again this week and see if it's OK for release. From your comment above it seems like the previous phylogenetic zoom level is what you want to "go back" to, in which case a back button on the tree (or similar) is the best solution.

My thoughts on the browser back button, or why we shouldn't use it. We can use this to revert the most recent user action, but we shouldn't. The general best practice seems to be that navigating to a materially different page should add an entry to the history stack (allowing the back button to go back to the previous page). Auspice does this when you change datasets, for instance. If we change this so that every action -- zooming the tree, zooming the map, animating, filtering -- adds an entry to the browser history, then you quickly loose the ability to go back to a page pre-auspice, and you also may not be able to go back to your previous tree zoom quickly either. (Not to mention that we'd have to change how we store state in the URL.) There are sites around the internet that do this, and I find them generally frustrating to use.

jameshadfield avatar Nov 01 '21 00:11 jameshadfield

Ah yes, I mixed up the browser back button and PR #1403. Looking forward to that being testable!

corneliusroemer avatar Nov 01 '21 01:11 corneliusroemer