Skip to content

Commit 58f9bb8

Browse files
committed
TraceManager should only delete traces that it has added itself
1 parent 2368c0c commit 58f9bb8

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

inst/htmlwidgets/plotly.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -595,8 +595,8 @@ TraceManager.prototype.updateSelection = function(group, keys) {
595595
var nNewTraces = this.gd.data.length - this.origData.length;
596596
if (keys === null || !this.highlight.persistent && nNewTraces > 0) {
597597
var tracesToRemove = [];
598-
for (var i = this.origData.length; i < this.gd.data.length; i++) {
599-
tracesToRemove.push(i);
598+
for (var i = 0; i < this.gd.data.length; i++) {
599+
if (this.gd.data[i]._isCrosstalkTrace) tracesToRemove.push(i);
600600
}
601601
Plotly.deleteTraces(this.gd, tracesToRemove);
602602
this.groupSelections[group] = keys;
@@ -678,6 +678,7 @@ TraceManager.prototype.updateSelection = function(group, keys) {
678678
// (necessary for updating frames to reflect the selection traces)
679679
trace._originalIndex = i;
680680
trace._newIndex = this.gd._fullData.length + traces.length;
681+
trace._isCrosstalkTrace = true;
681682
traces.push(trace);
682683
}
683684
}

0 commit comments

Comments
 (0)