From 3172d44fb324a9c478d6f878c2b89cecc3a4ac88 Mon Sep 17 00:00:00 2001 From: milandomazet <125308248+milandomazet@users.noreply.github.com> Date: Thu, 8 Aug 2024 15:52:37 +0200 Subject: [PATCH] Fix Merged track popup bug (#1869) --- js/feature/mergedTrack.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/js/feature/mergedTrack.js b/js/feature/mergedTrack.js index a7f3e1a87..3eace8bc6 100644 --- a/js/feature/mergedTrack.js +++ b/js/feature/mergedTrack.js @@ -227,7 +227,14 @@ class MergedTrack extends TrackBase { const promises = this.tracks.map((t) => t.getFeatures(chr, bpStart, bpEnd, bpPerPixel)) const featureArrays = await Promise.all(promises) - return new MergedFeatureCollection(featureArrays) + + if (featureArrays.every((arr) => arr.length === 0)){ + return new MergedFeatureCollection([], []) + } + else { + const trackNames = this.tracks.map((t) => t.name) + return new MergedFeatureCollection(featureArrays, trackNames) + } } draw(options) { @@ -446,8 +453,11 @@ class MergedTrack extends TrackBase { class MergedFeatureCollection { - constructor(featureArrays) { + constructor(featureArrays,trackNames) { this.featureArrays = featureArrays + //trackNames is needed for the popup data to populate track names + //preserving the order of the actual tracks + this.trackNames = trackNames } getMax(start, end) {