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: allow beforeTooltipDraw to be cancelable #10598

Merged
merged 3 commits into from
Aug 22, 2022

Conversation

GrantHynd
Copy link
Contributor

Resolves #10581

@GrantHynd
Copy link
Contributor Author

I will put together a quick example in a bit, but I confirmed the change works locally.

@GrantHynd
Copy link
Contributor Author

Was going to link to a code sandbox example, but I can not seem to be able to reference my Github branch. Is there a recommended way to share remote example implementations of branches? Or is it always a case of locally pulling?

@stockiNail
Copy link
Contributor

@GrantHynd maybe we should change the type definition of the hook as well, adding , cancelable: true }

Chart.js/types/index.d.ts

Lines 2573 to 2582 in 3df687a

/**
* @desc Called before drawing the `tooltip`. If any plugin returns `false`,
* the tooltip drawing is cancelled until another `render` is triggered.
* @param {Chart} chart - The chart instance.
* @param {object} args - The call arguments.
* @param {Tooltip} args.tooltip - The tooltip.
* @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;

etimberg
etimberg previously approved these changes Aug 15, 2022
Copy link
Collaborator

@LeeLenaleee LeeLenaleee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As @stockiNail pointed out, the typings need an update

@LeeLenaleee LeeLenaleee added this to the Version 4.0 milestone Aug 17, 2022
@GrantHynd
Copy link
Contributor Author

👍 will update that today.

@LeeLenaleee LeeLenaleee merged commit 75793eb into chartjs:master Aug 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can not cancel draw of tooltip using beforeTooltipDraw
6 participants