-
Notifications
You must be signed in to change notification settings - Fork 94
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 tooltip not updating properly #290
Conversation
Codecov Report
@@ Coverage Diff @@
## master #290 +/- ##
==========================================
- Coverage 88.29% 88.17% -0.12%
==========================================
Files 82 82
Lines 1051 1049 -2
Branches 203 204 +1
==========================================
- Hits 928 925 -3
- Misses 107 108 +1
Partials 16 16
Continue to review full report at Codecov.
|
|
||
useEffect(() => { | ||
const chartObj = chart.object; | ||
chartObj.tooltip = new Highcharts.Tooltip(chartObj, { | ||
updateTooltip(chart, { | ||
...(Highcharts.defaultOptions && Highcharts.defaultOptions.tooltip), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this line isn't part of this PR, but perhaps it should be moved into updateTooltip
below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it can be moved there as updateTooltip is called with only modifiedProps too. Then updateTooltip would reset non modifiedprops to defaults.
@@ -36,8 +35,9 @@ const Tooltip = memo(props => { | |||
}); | |||
|
|||
const updateTooltip = (chart, config) => { | |||
const tooltip = chart.object.tooltip; | |||
tooltip.update(config); | |||
chart.update({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May need to check that this, doesn't undo #226 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, just noticed you already referenced this bug on #289 - apologies
This fixes #289.
Now the Tooltip does not get recreated on mount, which might lead to settings leaking from previous tooltip options. But now both pointFormat and enabled props work at the same time.
It might be possible to store chart.options.tooltip.userOptions on mount and restore it on unmount, but that might cause more trouble.
@whawker what do you think?