wikitree / wikitree-dynamic-tree

Dynamically generated and browsed graphical family tree
MIT License
26 stars 20 forks source link

Reset state properly when closing a view #253

Closed faceless2 closed 2 weeks ago

faceless2 commented 1 month ago

While working on SlippyTree I did some testing swapping between various views, and found quite a few of them didn't clean up after themselves properly when closed. This PR fixes all the ones I found - I've broken it down into one checkin for each view so they can be cherry picked if that's preferred.

The main issues were classes or style rules being added to view-container and either not being removed afterwards, or being replaced with some sort of default value, eg auto. As any values set with style are going to override anything in the CSS stylesheets, style properties added have to be removed, not just set to auto.

To see why this is needed, try loading first (eg) Family Timeline and then changing to another view - you'll see there are still style rules set on the view-container. Switch from Family Timeline to SlippyTree and you'll see a double horizontal scrollbar because of a style rule left on view-container by Family Timeline.

The correct way to fix this is for each view to completely clean up after itself which is what this PR will fix.

I also caught oneNameTree's callback continuing to run when I triggered a load and then quickly changed view - that's fixed here too.