OneZoom / OZtree

OneZoom Tree of Life Explorer
Other
91 stars 20 forks source link

Settings are reset upon clicking "Popular places" links #870

Closed wolfmanstout closed 3 months ago

wolfmanstout commented 3 months ago

If I click on one of the convenient "popular places" links listed when hovering over the search bar, it resets any settings I've changed, such as the visualization shape. This is because it is not passing along the query args.

Simply passing along the query args when generating these links wouldn't truly fix the issue, because this list is populated when the page is first loaded and settings are generally changed after that point. These links either need to invoke javascript that dynamically defines where to navigate to, or else they need to be repopulated any time the query args are changed.

This bug is also present in a lesser form for the links that show up after a search query is entered: if the settings are changed after this point and then one of the links is clicked, it'll reset the settings (for the reason explained above, that the query arg changes are not propagated).

lentinj commented 3 months ago

The links are simply /life/@species, without any local state. We make no attempt to add this state---as you say, it'd get stale. What (should) happen is we intercept the link and use set_treestate to do the changes to the tree instead:

https://github.com/OneZoom/OZtree/blob/889026e68377ae306e8f3ffc60e16223803420cc/views/treeviewer/layout.html#L226-L227

This generally seems to work, and we have no reason to propagate existing query arguments, since set_treestate only changes the tree state we asked it to. So your settings are preserved.

However, it's not perfect:

My guess is you're experiencing the latter, a javascript error is being masked by the navigation to a fresh page, which has none of your settings.

wolfmanstout commented 3 months ago

Thanks for pointing me in the right direction. I will send a pull request shortly to fix. As it turns out, this is a bug in set_treestate that occurs even if it is called directly via the JS console. It was introduced in https://github.com/OneZoom/OZtree/commit/fe7bd7b8dd3220b24d0cbbf9c71c133d587362bc.