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 tooltip not updating properly #290

Merged
merged 1 commit into from
Jun 4, 2020
Merged

Conversation

anajavi
Copy link
Collaborator

@anajavi anajavi commented May 22, 2020

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?

@anajavi anajavi requested a review from whawker May 22, 2020 08:34
@codecov-commenter
Copy link

codecov-commenter commented May 22, 2020

Codecov Report

Merging #290 into master will decrease coverage by 0.11%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            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              
Impacted Files Coverage Δ
...t-jsx-highcharts/src/components/Tooltip/Tooltip.js 100.00% <100.00%> (ø)
packages/react-jsx-highcharts/test/test-utils.js 78.94% <0.00%> (-5.27%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ba9fe13...c76bd42. Read the comment docs.


useEffect(() => {
const chartObj = chart.object;
chartObj.tooltip = new Highcharts.Tooltip(chartObj, {
updateTooltip(chart, {
...(Highcharts.defaultOptions && Highcharts.defaultOptions.tooltip),
Copy link
Owner

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?

Copy link
Collaborator Author

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({
Copy link
Owner

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)

Copy link
Owner

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

@whawker whawker merged commit 1e4b50d into master Jun 4, 2020
@anajavi anajavi deleted the fix/tooltip-pointFormat branch October 23, 2020 07:28
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 pointFormat not updating
3 participants