Skip to content

fix(event-display): support 1D linkedTracks in colorTracksByVertex - #1074

Open
RuhaaBhalerao wants to merge 1 commit into
HSF:mainfrom
RuhaaBhalerao:fix/color-tracks-by-vertex-1d-arrays
Open

RuhaaBhalerao wants to merge 1 commit into
HSF:mainfrom
RuhaaBhalerao:fix/color-tracks-by-vertex-1d-arrays

Conversation

@RuhaaBhalerao

Copy link
Copy Markdown
Contributor

Summary of Changes

In #977, linkedTrackCollection was extended to an array of collection names (string[]) and linkedTracks to an array of track index lists (number[][]) to support vertices linking across multiple track collections.

However, loaders such as JiveXMLLoader and existing/legacy event datasets store linkedTrackCollection as a single string (e.g. 'Tracks') and linkedTracks as a 1D list of track indices (e.g. [0, 1, 2]).

When a user selects "Color by → Vertex" on such events:

  1. linkedTrackCollection.indexOf(collectionName) returns 0.
  2. linkedTracks[collectionIndex] evaluates to linkedTracks[0], which is the first track index (number), rather than an array.
  3. Calling linkedTracks[collectionIndex].forEach(...) immediately throws an uncaught exception:
    TypeError: linkedTracks[collectionIndex].forEach is not a function.
  4. Furthermore, checking linkedTrackCollection?.includes(collectionName) on a string matched substrings (e.g. 'Tracks' matched 'ack'), causing wrong collection indices to be computed.

Changes:

  • In ColorManager.colorTracksByVertex:
    • Handle both 2D (number[][]) and 1D (number[]) linkedTracks structures cleanly.
    • Check exact equality (linkedTrackCollection === collectionName) when linkedTrackCollection is a string to prevent false-positive substring matches.

Testing

  • Added unit tests in color-manager.test.ts:
    • Verified coloring tracks when linkedTracks is a 2D array ([['Tracks']], [[0]]).
    • Verified coloring tracks when linkedTracks is a 1D array ('Tracks', [0]) without throwing TypeError.
    • Verified that non-matching collection names do not color unrelated tracks.

@github-actions

Copy link
Copy Markdown

🚀 Preview deployed: http://phoenix-pr-1074.surge.sh

Built from 6c83b83.

@RuhaaBhalerao

Copy link
Copy Markdown
Contributor Author

Hi @EdwardMoyse,

Following up on the vertex coloring discussion in #948 and #977, I noticed that while #977 added support for multi-collection 2D linkedTracks (number[][]), loaders like JiveXMLLoader and legacy event datasets store linkedTracks as a 1D array of indices (number[]) and linkedTrackCollection as a string.

When choosing "Color by → Vertex" on JiveXML data, linkedTracks[collectionIndex] evaluates to a number rather than an array, causing an unhandled TypeError: linkedTracks[collectionIndex].forEach is not a function.

This PR updates colorTracksByVertex to defensively support both 1D and 2D linkedTracks representations (and exact string matches for linkedTrackCollection), and adds unit tests covering both formats.

Whenever you have a chance, I'd appreciate your review!

This branch was successfully deployed

1 active deployment
pull-request — 6c83b831 Deployed Nov 12, 2026 by github-actions[bot]
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.

1 participant