[codevoyager] fix: persist legend track visibility state across configuration changes#498
Open
codevoyager-ai-dev wants to merge 1 commit into
Open
Conversation
…guration changes The issue was that unchecked tracks in the Legend would reset to checked whenever the configuration changed (reference, region, etc.). This happened because the hidden state was stored only in module-level variables in tubemap.js that were lost when the visualization was recreated. Changes: - Added hiddenTrackIds and visibilityChangedCallback to tubemap.js config - Added setHiddenTrackIds/getHiddenTrackIds/setVisibilityChangedCallback exports - Modified create() to apply persisted hidden tracks and set track types - Modified changeTrackVisibility/changeAllTracksVisibility to update hidden state - Modified drawLegend() to use inputTracks and reflect actual hidden state - Added hiddenTracks to visOptions in App.js for React-level persistence - Added onTrackVisibilityChanged callback chain: App -> TubeMapContainer -> TubeMap - TubeMap component sets the visibility callback and hidden track IDs on the tubemap Closes vgteam#464
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.
Issue
When viewing genome graphs with many tracks (e.g., from Cactus which generates 'fake' ancestral genomes), unchecking unwanted tracks in the Legend was tedious because the checked/unchecked state was lost whenever the configuration changed (switching reference, region, removing variants, or node sequences).
Closes #464
Solution
The checked/unchecked state of haplotype tracks in the Legend is now persisted in React state (App.js visOptions.hiddenTracks) and flows through the component hierarchy to the D3 tubemap rendering engine.
Key changes:
src/util/tubemap.js
hiddenTrackIds(Set) andvisibilityChangedCallbackto the module configsetHiddenTrackIds(),getHiddenTrackIds(),setVisibilityChangedCallback()create()now applies persisted hidden tracks toinputTracksafter deep copychangeTrackVisibility()andchangeAllTracksVisibility()update the hidden state and notify React via callbackdrawLegend()now iterates overinputTracks(all tracks, not just the filtered subset) and sets checkbox state based onhiddenTrackIdssrc/App.js
hiddenTracks: []tovisOptionsstate (persists across viewTarget changes)handleTrackVisibilityChangedto updatehiddenTrackswhen the user toggles trackssrc/components/TubeMap.js / TubeMapContainer.js
onTrackVisibilityChangedprop chainsetHiddenTrackIds()on every rendersrc/util/tubemap.test.js
setHiddenTrackIds,getHiddenTrackIds, andsetVisibilityChangedCallbackTesting