Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit active element changes to chartArea #9970

Merged
merged 3 commits into from
Dec 8, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
CC2
  • Loading branch information
kurkle committed Dec 8, 2021
commit e7e944a979ecb60014893837697d666b8a471537
26 changes: 18 additions & 8 deletions src/core/core.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,22 @@ function moveNumericKeys(obj, start, move) {
}
}

/**
* @param {ChartEvent} e
* @param {ChartEvent|null} lastEvent
* @param {boolean} inChartArea
* @param {boolean} isClick
* @returns {ChartEvent|null}
*/
function determineLastEvent(e, lastEvent, inChartArea, isClick) {
if (!inChartArea || e.type === 'mouseout') {
return null;
}
if (isClick) {
return lastEvent;
}
return e;
}

class Chart {

Expand Down Expand Up @@ -1159,16 +1175,10 @@ class Chart {
// - it would be expensive.
const useFinalPosition = replay;
const active = this._getActiveElements(e, lastActive, inChartArea, useFinalPosition);
let lastEvent = null;
const isClick = _isClickEvent(e);
const lastEvent = determineLastEvent(e, this._lastEvent, inChartArea, isClick);

if (inChartArea) {
const isClick = _isClickEvent(e);

if (e.type !== 'mouseout') {
// This event should be replayed in subsequent update
lastEvent = isClick ? this._lastEvent : e;
}

// Set _lastEvent to null while we are processing the event handlers.
// This prevents recursion if the handler calls chart.update()
this._lastEvent = null;
Expand Down