From: Grant Hynd Date: Mon, 22 Aug 2022 15:33:02 +0000 (+0100) Subject: fix: allow beforeTooltipDraw to be cancelable (#10598) X-Git-Tag: v4.0.0~49 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=75793eb86fc38d092bc00a4c4f26beb7f20bf0b7;p=thirdparty%2FChart.js.git fix: allow beforeTooltipDraw to be cancelable (#10598) --- diff --git a/src/plugins/plugin.tooltip.js b/src/plugins/plugin.tooltip.js index bb408a917..29f6e05f1 100644 --- a/src/plugins/plugin.tooltip.js +++ b/src/plugins/plugin.tooltip.js @@ -1241,7 +1241,7 @@ export default { tooltip }; - if (chart.notifyPlugins('beforeTooltipDraw', args) === false) { + if (chart.notifyPlugins('beforeTooltipDraw', {...args, cancelable: true}) === false) { return; } diff --git a/types/index.d.ts b/types/index.d.ts index 430d58904..4daf093ba 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -2575,7 +2575,7 @@ export interface ExtendedPlugin< * @param {object} options - The plugin options. * @returns {boolean} `false` to cancel the chart tooltip drawing. */ - beforeTooltipDraw?(chart: Chart, args: { tooltip: Model }, options: O): boolean | void; + beforeTooltipDraw?(chart: Chart, args: { tooltip: Model, cancelable: true }, options: O): boolean | void; /** * @desc Called after drawing the `tooltip`. Note that this hook will not * be called if the tooltip drawing has been previously cancelled.