Don't run tooltip content callbacks when all items are filtered out#12275
Open
chang-pro wants to merge 2 commits into
Open
Don't run tooltip content callbacks when all items are filtered out#12275chang-pro wants to merge 2 commits into
chang-pro wants to merge 2 commits into
Conversation
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
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #12274
When the tooltip
filtercallback removes every active item,update()still rangetTitle/getBeforeBody/getBody/getAfterBody/getFooterwith an emptyTooltipItemarray (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.lengthdoes, 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).