-
Notifications
You must be signed in to change notification settings - Fork 77
fix: only remove tooltips relating to a single vis #167
Conversation
5f8ffc7
to
6608b58
Compare
Codecov Report
@@ Coverage Diff @@
## master #167 +/- ##
==========================================
- Coverage 25.9% 25.14% -0.76%
==========================================
Files 8 8
Lines 166 171 +5
Branches 10 10
==========================================
Hits 43 43
- Misses 122 127 +5
Partials 1 1
Continue to review full report at Codecov.
|
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.
Overall LGTM, have minor comments on some pessimistic edge cases.
|
||
function componentWillUnmount() { | ||
hideTooltips(true); | ||
const { id } = this.props; // eslint-disable-line babel/no-invalid-this | ||
if (id) { |
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.
Can id
be 0
?
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.
updated to id != null
@@ -254,6 +256,7 @@ function nvd3Vis(element, props) { | |||
const container = element; | |||
container.innerHTML = ''; | |||
const activeAnnotationLayers = annotationLayers.filter(layer => layer.show); | |||
const chartId = container.parentElement.id || null; |
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.
perhaps also check if parentElement
is not null.
Also, do we want to prevent accidents if id
is 0
which is falsy?
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.
updated
4e7c430
to
c360a8d
Compare
c360a8d
to
91aaac7
Compare
* build: bump build-config * test: fix typings in mock data
🐛 Bug Fix
When rerendering charts, we were removing all tooltips for every chart from the dom instead of just the one owned by the rerendering chart. This would break pages with multiple nvd3 charts on them (basically all superset dashboards). It can be easily reproed with dashboards with multiple tabs with the following steps:
I fixed this issue by uniquely identifying charts by the passed in id and applying this id to the tooltips as well. When rerendering or unmounting charts now, if an id was passed in then we only remove the tooltip belonging to that chart. If no ids are passed, then we retain the current behavior.