Skip to content

Commit e14cc9a

Browse files
committed
fix(ssr): hovering legend items should not trigger tooltip
fix a bug introduced by #18381
1 parent 61af513 commit e14cc9a

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

src/component/legend/LegendView.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -226,12 +226,14 @@ class LegendView extends ComponentView {
226226
.on('mouseover', curry(dispatchHighlightAction, seriesModel.name, null, api, excludeSeriesId))
227227
.on('mouseout', curry(dispatchDownplayAction, seriesModel.name, null, api, excludeSeriesId));
228228

229-
itemGroup.eachChild(child => {
230-
const ecData = getECData(child);
231-
ecData.seriesIndex = seriesModel.seriesIndex;
232-
ecData.dataIndex = dataIndex;
233-
ecData.ssrType = 'legend';
234-
});
229+
if (ecModel.ssr) {
230+
itemGroup.eachChild(child => {
231+
const ecData = getECData(child);
232+
ecData.seriesIndex = seriesModel.seriesIndex;
233+
ecData.dataIndex = dataIndex;
234+
ecData.ssrType = 'legend';
235+
});
236+
}
235237

236238
legendDrawnMap.set(name, true);
237239
}
@@ -277,12 +279,14 @@ class LegendView extends ComponentView {
277279
.on('mouseover', curry(dispatchHighlightAction, null, name, api, excludeSeriesId))
278280
.on('mouseout', curry(dispatchDownplayAction, null, name, api, excludeSeriesId));
279281

280-
itemGroup.eachChild(child => {
281-
const ecData = getECData(child);
282-
ecData.seriesIndex = seriesModel.seriesIndex;
283-
ecData.dataIndex = dataIndex;
284-
ecData.ssrType = 'legend';
285-
});
282+
if (ecModel.ssr) {
283+
itemGroup.eachChild(child => {
284+
const ecData = getECData(child);
285+
ecData.seriesIndex = seriesModel.seriesIndex;
286+
ecData.dataIndex = dataIndex;
287+
ecData.ssrType = 'legend';
288+
});
289+
}
286290

287291
legendDrawnMap.set(name, true);
288292
}

src/component/tooltip/TooltipView.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,11 @@ class TooltipView extends ComponentView {
463463
this._showAxisTooltip(dataByCoordSys, e);
464464
}
465465
else if (el) {
466+
const ecData = getECData(el);
467+
if (ecData.ssrType === 'legend') {
468+
// Don't trigger tooltip for legend tooltip item
469+
return;
470+
}
466471
this._lastDataByCoordSys = null;
467472

468473
let seriesDispatcher: Element;

0 commit comments

Comments
 (0)