Skip to content

Commit 1a08754

Browse files
committed
Include shapes with legendgroup when handling legend click
1 parent 61b8186 commit 1a08754

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

src/components/legend/handle_click.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,9 @@ exports.handleItemClick = function handleItemClick(g, gd, legendObj, mode) {
4444
var hiddenSlices = fullLayout.hiddenlabels ? fullLayout.hiddenlabels.slice() : [];
4545

4646
var fullData = gd._fullData;
47-
var shapesWithLegend = (fullLayout.shapes || []).filter(function (d) {
48-
return d.showlegend;
49-
});
50-
var allLegendItems = fullData.concat(shapesWithLegend);
47+
// legendgroup membership matters even when showlegend is false, so togglegroup reaches hidden group peers.
48+
const shapesInLegend = (fullLayout.shapes || []).filter((d) => d.showlegend || d.legendgroup);
49+
var allLegendItems = fullData.concat(shapesInLegend);
5150

5251
var fullTrace = legendItem.trace;
5352
if (fullTrace._isShape) {
@@ -295,10 +294,8 @@ exports.handleTitleClick = function handleTitleClick(gd, legendObj, mode) {
295294
const fullLayout = gd._fullLayout;
296295
const fullData = gd._fullData;
297296
const legendId = helpers.getId(legendObj);
298-
const shapesWithLegend = (fullLayout.shapes || []).filter(function (d) {
299-
return d.showlegend;
300-
});
301-
const allLegendItems = fullData.concat(shapesWithLegend);
297+
const shapesInLegend = (fullLayout.shapes || []).filter((d) => d.showlegend || d.legendgroup);
298+
const allLegendItems = fullData.concat(shapesInLegend);
302299

303300
function isInLegend(item) {
304301
return (item.legend || 'legend') === legendId;

0 commit comments

Comments
 (0)