]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
fix: allow beforeTooltipDraw to be cancelable (#10598)
authorGrant Hynd <grant.hynd@gmail.com>
Mon, 22 Aug 2022 15:33:02 +0000 (16:33 +0100)
committerGitHub <noreply@github.com>
Mon, 22 Aug 2022 15:33:02 +0000 (17:33 +0200)
src/plugins/plugin.tooltip.js
types/index.d.ts

index bb408a9177f53bbaa8b494418ca23a262baa178f..29f6e05f102a15cfb5c38d43b4c34a4454ccb6e4 100644 (file)
@@ -1241,7 +1241,7 @@ export default {
         tooltip
       };
 
-      if (chart.notifyPlugins('beforeTooltipDraw', args) === false) {
+      if (chart.notifyPlugins('beforeTooltipDraw', {...args, cancelable: true}) === false) {
         return;
       }
 
index 430d5890421813a5d7df8d117c71eac5e7fc01b1..4daf093ba14a8f658b6b0d9275ebcaf08581b643 100644 (file)
@@ -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.