Skip to content

Don't run tooltip content callbacks when all items are filtered out#12275

Open
chang-pro wants to merge 2 commits into
chartjs:masterfrom
chang-pro:fix-tooltip-filtered-callbacks
Open

Don't run tooltip content callbacks when all items are filtered out#12275
chang-pro wants to merge 2 commits into
chartjs:masterfrom
chang-pro:fix-tooltip-filtered-callbacks

Conversation

@chang-pro

Copy link
Copy Markdown

Fixes #12274

When the tooltip filter callback removes every active item, update() still ran getTitle/getBeforeBody/getBody/getAfterBody/getFooter with an empty TooltipItem array (breaking user callbacks that rely on the array never being empty), and then showed an empty tooltip.

The items are now created before deciding visibility, and an empty result hides the tooltip exactly like !active.length does, so content callbacks never see an empty array.

Repro from the issue: https://codepen.io/ajuvonen/pen/OPWvmwG

Added a regression test (fails without the fix); the tooltip plugin suite passes (41 specs).

The title callback (and the other content callbacks) ran with an empty
tooltip item array when the filter callback removed every active item,
and the empty tooltip was still shown. Hide the tooltip instead, like
when nothing is active. Fixes chartjs#12274
Copilot AI review requested due to automatic review settings July 12, 2026 18:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

When items were filtered after being visible, the stale body could be
drawn with the freshly cleared label colors during fade-out, crashing
_drawColorBox. Clear the content in that case and anchor the caret to
the positioner result so an identical event is no longer reported as a
position change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tooltip title callback is run with empty parameter array for filtered tooltips

2 participants