Skip to content

Commit 5f1d470

Browse files
author
Saber Sun
committed
bugfix: issue 11801
1 parent 0ca1b6e commit 5f1d470

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/plugins/plugin.tooltip.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -630,13 +630,13 @@ export class Tooltip extends Element {
630630
return tooltipItems;
631631
}
632632

633-
update(changed, replay) {
633+
update(changed, replay, inChartArea = true) {
634634
const options = this.options.setContext(this.getContext());
635635
const active = this._active;
636636
let properties;
637637
let tooltipItems = [];
638638

639-
if (!active.length) {
639+
if (!active.length || !inChartArea) {
640640
if (this.opacity !== 0) {
641641
properties = {
642642
opacity: 0
@@ -1147,7 +1147,7 @@ export class Tooltip extends Element {
11471147
const positionChanged = this._positionChanged(active, e);
11481148

11491149
// Remember Last Actives
1150-
const changed = replay || !_elementsEqual(active, lastActive) || positionChanged;
1150+
const changed = replay || !inChartArea || !_elementsEqual(active, lastActive) || positionChanged;
11511151

11521152
// Only handle target event on tooltip change
11531153
if (changed) {
@@ -1159,7 +1159,7 @@ export class Tooltip extends Element {
11591159
y: e.y
11601160
};
11611161

1162-
this.update(true, replay);
1162+
this.update(true, replay, inChartArea);
11631163
}
11641164
}
11651165

test/specs/plugin.tooltip.tests.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,7 @@ describe('Plugin.Tooltip', function() {
965965

966966
// First dispatch change event, should update tooltip
967967
await jasmine.triggerMouseEvent(chart, 'mousemove', firstPoint);
968-
expect(tooltip.update).toHaveBeenCalledWith(true, undefined);
968+
expect(tooltip.update).toHaveBeenCalledWith(true, undefined, true);
969969

970970
// Reset calls
971971
tooltip.update.calls.reset();
@@ -1028,15 +1028,15 @@ describe('Plugin.Tooltip', function() {
10281028

10291029
// First dispatch change event, should update tooltip
10301030
await jasmine.triggerMouseEvent(chart, 'mousemove', firstPoint);
1031-
expect(tooltip.update).toHaveBeenCalledWith(true, undefined);
1031+
expect(tooltip.update).toHaveBeenCalledWith(true, undefined, true);
10321032

10331033
// Reset calls
10341034
tooltip.update.calls.reset();
10351035

10361036
// Second dispatch change event (same event), should update tooltip
10371037
// because position mode is 'nearest'
10381038
await jasmine.triggerMouseEvent(chart, 'mousemove', secondPoint);
1039-
expect(tooltip.update).toHaveBeenCalledWith(true, undefined);
1039+
expect(tooltip.update).toHaveBeenCalledWith(true, undefined, true);
10401040
});
10411041

10421042
describe('positioners', function() {

0 commit comments

Comments
 (0)