fix: height graph renders correctly when reopened#349
Merged
nilsnolde merged 1 commit intovalhalla:masterfrom Mar 6, 2026
Merged
fix: height graph renders correctly when reopened#349nilsnolde merged 1 commit intovalhalla:masterfrom
nilsnolde merged 1 commit intovalhalla:masterfrom
Conversation
|
Preview is ready! 🚀 You can view it here: https://valhalla-app-tests.gis-ops.com/349 |
nilsnolde
approved these changes
Mar 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
isExpandedto the dependency array:Now when
isExpandedchanges fromfalse→true, React re-runs the effect and draws the graph.Testing
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.