Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fde209f

Browse filesBrowse files
committed
trigger plotly_legendclick out of single-click timeout
1 parent 9a7cc14 commit fde209f
Copy full SHA for fde209f

File tree

2 files changed

+12
-10
lines changed
Filter options

2 files changed

+12
-10
lines changed

‎src/components/legend/draw.js

Copy file name to clipboardExpand all lines: src/components/legend/draw.js
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -375,20 +375,20 @@ function clickOrDoubleClick(gd, legend, legendItem, numClicks, evt) {
375375
evtData.group = trace._group;
376376
}
377377

378-
var returnVal;
378+
var clickVal = Events.triggerHandler(gd, 'plotly_legendclick', evtData);
379+
if(clickVal === false) return;
379380

380381
if(numClicks === 1) {
381382
legend._clickTimeout = setTimeout(function() {
382-
returnVal = Events.triggerHandler(gd, 'plotly_legendclick', evtData);
383-
if(returnVal !== false) handleClick(legendItem, gd, numClicks);
383+
handleClick(legendItem, gd, numClicks);
384384
}, DBLCLICKDELAY);
385385
}
386386
else if(numClicks === 2) {
387387
if(legend._clickTimeout) clearTimeout(legend._clickTimeout);
388388
gd._legendMouseDownTime = 0;
389389

390-
returnVal = Events.triggerHandler(gd, 'plotly_legenddoubleclick', evtData);
391-
if(returnVal !== false) handleClick(legendItem, gd, numClicks);
390+
var dblClickVal = Events.triggerHandler(gd, 'plotly_legenddoubleclick', evtData);
391+
if(dblClickVal !== false) handleClick(legendItem, gd, numClicks);
392392
}
393393
}
394394

‎test/jasmine/tests/legend_test.js

Copy file name to clipboardExpand all lines: test/jasmine/tests/legend_test.js
+7-5Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1340,17 +1340,19 @@ describe('legend interaction', function() {
13401340
reject('did not trigger ' + evtName);
13411341
}, 2 * DBLCLICKDELAY);
13421342

1343-
gd.on(evtName, function(d) {
1344-
hasBeenCalled = true;
1345-
_assert(d, exp);
1346-
});
1347-
gd.on('plotly_restyle', function() {
1343+
function done() {
13481344
if(hasBeenCalled) {
13491345
clearTimeout(to);
13501346
resolve();
13511347
}
1348+
}
1349+
1350+
gd.once(evtName, function(d) {
1351+
hasBeenCalled = true;
1352+
_assert(d, exp);
13521353
});
13531354

1355+
gd.once('plotly_restyle', done);
13541356
click(clickArg[0], clickArg[1])();
13551357
});
13561358
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.