Skip to content

Commit edc30ac

Browse files
committed
Reduce test delays and fix uncovered bug
Fixup double_click asset Cleanup legend item selection code in editable mode
1 parent 1fe3b08 commit edc30ac

File tree

3 files changed

+17
-18
lines changed

3 files changed

+17
-18
lines changed

src/components/legend/draw.js

+8-9
Original file line numberDiff line numberDiff line change
@@ -334,15 +334,13 @@ module.exports = function draw(gd) {
334334
if(dragged && xf !== undefined && yf !== undefined) {
335335
Plotly.relayout(gd, {'legend.x': xf, 'legend.y': yf});
336336
} else {
337-
var traces = [],
338-
clickedTrace;
339-
traces = fullLayout._infolayer.selectAll('g.traces').filter(function() {
340-
var bbox = this.getBoundingClientRect();
341-
return (e.clientX >= bbox.left && e.clientX <= bbox.right &&
342-
e.clientY >= bbox.top && e.clientY <= bbox.bottom);
343-
})[0];
344-
if(traces.length > 0) {
345-
clickedTrace = d3.select(traces[0]);
337+
var clickedTrace =
338+
fullLayout._infolayer.selectAll('g.traces').filter(function() {
339+
var bbox = this.getBoundingClientRect();
340+
return (e.clientX >= bbox.left && e.clientX <= bbox.right &&
341+
e.clientY >= bbox.top && e.clientY <= bbox.bottom);
342+
});
343+
if(clickedTrace.size() > 0) {
346344
if(numClicks === 1) {
347345
legend._clickTimeout = setTimeout(function() { handleClick(clickedTrace, gd, numClicks); }, DBLCLICKDELAY);
348346
} else if(numClicks === 2) {
@@ -458,6 +456,7 @@ function setupTraceToggle(g, gd) {
458456
if(legend._clickTimeout) {
459457
clearTimeout(legend._clickTimeout);
460458
}
459+
gd._legendMouseDownTime = 0;
461460
handleClick(g, gd, numClicks);
462461
}
463462
});

test/jasmine/assets/double_click.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
var click = require('./click');
2-
var DBLCLICKDELAY = require('@src/plots/cartesian/constants').DBLCLICKDELAY;
2+
var DBLCLICKDELAY = require('@src/constants/interactions').DBLCLICKDELAY;
33

44
module.exports = function doubleClick(x, y) {
55
return new Promise(function(resolve) {

test/jasmine/tests/legend_test.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ describe('legend interaction', function() {
661661
expect(gd._fullLayout.hiddenlabels.length).toBe(1);
662662
expect(gd._fullLayout.hiddenlabels[0]).toBe(legendLabel);
663663
done();
664-
}, DBLCLICKDELAY * 2);
664+
}, DBLCLICKDELAY + 20);
665665
});
666666
it('should fade legend item', function() {
667667
expect(+legendItem.parentNode.style.opacity).toBeLessThan(1);
@@ -672,7 +672,7 @@ describe('legend interaction', function() {
672672
setTimeout(function() {
673673
expect(gd._fullLayout.hiddenlabels.length).toBe(0);
674674
done();
675-
}, DBLCLICKDELAY * 2);
675+
}, DBLCLICKDELAY + 20);
676676
});
677677
it('should unfade legend item', function() {
678678
expect(+legendItem.parentNode.style.opacity).toBe(1);
@@ -689,7 +689,7 @@ describe('legend interaction', function() {
689689
expect(gd._fullLayout.hiddenlabels.length).toBe((legendItems.length - 1));
690690
expect(gd._fullLayout.hiddenlabels.indexOf(legendLabel)).toBe(-1);
691691
done();
692-
}, DBLCLICKDELAY);
692+
}, 20);
693693
});
694694
it('should fade other legend items', function() {
695695
var legendItemi;
@@ -710,7 +710,7 @@ describe('legend interaction', function() {
710710
setTimeout(function() {
711711
expect(gd._fullLayout.hiddenlabels.length).toBe(0);
712712
done();
713-
}, DBLCLICKDELAY);
713+
}, 20);
714714
});
715715
it('should unfade legend items', function() {
716716
var legendItemi;
@@ -747,7 +747,7 @@ describe('legend interaction', function() {
747747
setTimeout(function() {
748748
expect(gd.data[2].visible).toBe('legendonly');
749749
done();
750-
}, DBLCLICKDELAY * 2);
750+
}, DBLCLICKDELAY + 20);
751751
});
752752
it('should fade legend item', function() {
753753
expect(+legendItem.parentNode.style.opacity).toBeLessThan(1);
@@ -758,7 +758,7 @@ describe('legend interaction', function() {
758758
setTimeout(function() {
759759
expect(gd.data[2].visible).toBe(true);
760760
done();
761-
}, DBLCLICKDELAY * 2);
761+
}, DBLCLICKDELAY + 20);
762762
});
763763
it('should unfade legend item', function() {
764764
expect(+legendItem.parentNode.style.opacity).toBe(1);
@@ -779,7 +779,7 @@ describe('legend interaction', function() {
779779
}
780780
}
781781
done();
782-
}, DBLCLICKDELAY);
782+
}, 20);
783783
});
784784
it('should fade legend item', function() {
785785
var legendItemi;
@@ -802,7 +802,7 @@ describe('legend interaction', function() {
802802
expect(gd.data[i].visible).toBe(true);
803803
}
804804
done();
805-
}, DBLCLICKDELAY);
805+
}, 20);
806806
});
807807
it('should unfade legend items', function() {
808808
var legendItemi;

0 commit comments

Comments
 (0)