Skip to content

fix: height graph renders correctly when reopened#349

Merged
nilsnolde merged 1 commit intovalhalla:masterfrom
thisisharsh7:fix/heightgraph-reopen-blank
Mar 6, 2026
Merged

fix: height graph renders correctly when reopened#349
nilsnolde merged 1 commit intovalhalla:masterfrom
thisisharsh7:fix/heightgraph-reopen-blank

Conversation

@thisisharsh7
Copy link
Contributor

Fixes Issue

Closes #348

What's the problem?

The height graph shows up fine the first time you open it, but if you close it and reopen it, you just get a blank SVG with the legend at the bottom.

Why does this happen?

When you close the graph, React unmounts the SVG element. When you open it again, a fresh SVG gets mounted, but the D3 drawing code doesn't run because the useEffect dependencies haven't changed.

The useEffect was watching [data, dimensions, onHighlight], so React thinks "nothing changed, skip the effect". But the SVG element itself is brand new and needs to be drawn on.

The fix

Added isExpanded to the dependency array:

-  }, [data, dimensions, onHighlight]);
+  }, [data, dimensions, onHighlight, isExpanded]);

Now when isExpanded changes from falsetrue, React re-runs the effect and draws the graph.

Testing

  • Open height graph → works
  • Close and reopen → works now
  • Repeat multiple times → keeps working

Note: This PR description was written with assistance from AI tool. The code changes and bug investigation were done by me, and I've verified the fix works as expected.

@ghost
Copy link

ghost commented Mar 6, 2026

Preview is ready! 🚀 You can view it here: https://valhalla-app-tests.gis-ops.com/349

@nilsnolde nilsnolde enabled auto-merge (squash) March 6, 2026 06:07
@nilsnolde nilsnolde merged commit 770c079 into valhalla:master Mar 6, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Height graph appears blank when reopened after closing

2 participants