diff --git a/superset/assets/src/visualizations/nvd3/NVD3Vis.js b/superset/assets/src/visualizations/nvd3/NVD3Vis.js index 062906e5f3..e7f9445a14 100644 --- a/superset/assets/src/visualizations/nvd3/NVD3Vis.js +++ b/superset/assets/src/visualizations/nvd3/NVD3Vis.js @@ -712,7 +712,7 @@ function nvd3Vis(element, props) { .call(chart); // on scroll, hide tooltips. throttle to only 4x/second. - window.addEventListener('scroll', throttle(hideTooltips, 250)); + window.addEventListener('scroll', throttle(() => hideTooltips(element), 250)); // The below code should be run AFTER rendering because chart is updated in call() if (isTimeSeries && activeAnnotationLayers.length > 0) { @@ -936,7 +936,7 @@ function nvd3Vis(element, props) { // hide tooltips before rendering chart, if the chart is being re-rendered sometimes // there are left over tooltips in the dom, // this will clear them before rendering the chart again. - hideTooltips(); + hideTooltips(element); nv.addGraph(drawGraph); } diff --git a/superset/assets/src/visualizations/nvd3/utils.js b/superset/assets/src/visualizations/nvd3/utils.js index 92ac3dd9c3..a6d4842226 100644 --- a/superset/assets/src/visualizations/nvd3/utils.js +++ b/superset/assets/src/visualizations/nvd3/utils.js @@ -165,10 +165,12 @@ export function generateBubbleTooltipContent({ return s; } -export function hideTooltips() { - const targets = document.querySelectorAll('.nvtooltip'); - if (targets.length > 0) { - targets.forEach(t => t.remove()); +export function hideTooltips(element) { + if (element) { + const targets = element.querySelectorAll('.nvtooltip'); + if (targets.length > 0) { + targets.forEach(t => t.remove()); + } } }