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

fix: mokeypatch Pointer.onDocumentMouseMove method (#7118) #7127

Merged
merged 1 commit into from
Feb 13, 2024
Merged
Changes from all commits
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
23 changes: 23 additions & 0 deletions packages/charts/src/vaadin-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import 'highcharts/es-modules/masters/modules/bullet.src.js';
import { FlattenedNodesObserver } from '@polymer/polymer/lib/utils/flattened-nodes-observer.js';
import { beforeNextRender } from '@polymer/polymer/lib/utils/render-status.js';
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
import Pointer from 'highcharts/es-modules/Core/Pointer.js';
import Highcharts from 'highcharts/es-modules/masters/highstock.src.js';
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
Expand Down Expand Up @@ -69,6 +70,28 @@ export function deepMerge(target, source) {
/* eslint-enable no-invalid-this */
});

// Monkeypatch the onDocumentMouseMove method to fix the check for the source of the event
// Due to the fact that the event is attached to the document, the target of the event is
// the <vaadin-chart> element, so we need to use the composedPath to get the actual target (#7107)
Pointer.prototype.onDocumentMouseMove = function (e) {
const chart = this.chart;
const chartPosition = this.chartPosition;
const pEvt = this.normalize(e, chartPosition);
const tooltip = chart.tooltip;
// If we're outside, hide the tooltip
if (
chartPosition &&
(!tooltip || !tooltip.isStickyOnContact()) &&
!chart.isInsidePlot(pEvt.chartX - chart.plotLeft, pEvt.chartY - chart.plotTop, {
visiblePlotOnly: true,
}) &&
// Use the first element from the composed path instead of the actual target
!this.inClass(pEvt.composedPath()[0], 'highcharts-tracker')
) {
this.reset();
}
};

// Init Highcharts global language defaults
// No data message should be empty by default
Highcharts.setOptions({ lang: { noData: '' } });
Expand Down
Loading