Skip to content

Commit

Permalink
bugfix: issue 11801
Browse files Browse the repository at this point in the history
  • Loading branch information
Saber Sun committed Jul 16, 2024
1 parent 0ca1b6e commit 5f1d470
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/plugins/plugin.tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -630,13 +630,13 @@ export class Tooltip extends Element {
return tooltipItems;
}

update(changed, replay) {
update(changed, replay, inChartArea = true) {
const options = this.options.setContext(this.getContext());
const active = this._active;
let properties;
let tooltipItems = [];

if (!active.length) {
if (!active.length || !inChartArea) {
if (this.opacity !== 0) {
properties = {
opacity: 0
Expand Down Expand Up @@ -1147,7 +1147,7 @@ export class Tooltip extends Element {
const positionChanged = this._positionChanged(active, e);

// Remember Last Actives
const changed = replay || !_elementsEqual(active, lastActive) || positionChanged;
const changed = replay || !inChartArea || !_elementsEqual(active, lastActive) || positionChanged;

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

this.update(true, replay);
this.update(true, replay, inChartArea);
}
}

Expand Down
6 changes: 3 additions & 3 deletions test/specs/plugin.tooltip.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,7 @@ describe('Plugin.Tooltip', function() {

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

// Reset calls
tooltip.update.calls.reset();
Expand Down Expand Up @@ -1028,15 +1028,15 @@ describe('Plugin.Tooltip', function() {

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

// Reset calls
tooltip.update.calls.reset();

// Second dispatch change event (same event), should update tooltip
// because position mode is 'nearest'
await jasmine.triggerMouseEvent(chart, 'mousemove', secondPoint);
expect(tooltip.update).toHaveBeenCalledWith(true, undefined);
expect(tooltip.update).toHaveBeenCalledWith(true, undefined, true);
});

describe('positioners', function() {
Expand Down

0 comments on commit 5f1d470

Please sign in to comment.