From b572b87f97b6e09dc3b5bce784a1f32b399c15ad Mon Sep 17 00:00:00 2001 From: Andrew Blomenberg Date: Wed, 30 Sep 2020 12:48:14 -0600 Subject: [PATCH 1/2] Fixed bug caused by emptying the modebar div without resetting the modebar state --- src/plot_api/plot_api.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plot_api/plot_api.js b/src/plot_api/plot_api.js index 4baa8a329e5..43a3e2c0458 100644 --- a/src/plot_api/plot_api.js +++ b/src/plot_api/plot_api.js @@ -3749,6 +3749,7 @@ function makePlotFramework(gd) { .classed('main-svg', true); fullLayout._modebardiv = fullLayout._paperdiv.append('div'); + delete fullLayout._modeBar; fullLayout._hoverpaper = fullLayout._paperdiv.append('svg') .classed('main-svg', true); From 629e21dc02ddd0cd484534fde634d9ec79821bee Mon Sep 17 00:00:00 2001 From: "Andrew.Blomenberg" Date: Thu, 1 Oct 2020 10:23:57 -0600 Subject: [PATCH 2/2] Added test to check if modebar html is present when switching between different types of plots --- test/jasmine/tests/modebar_test.js | 42 ++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/test/jasmine/tests/modebar_test.js b/test/jasmine/tests/modebar_test.js index 66c7b7b9a9a..b97d81a6960 100644 --- a/test/jasmine/tests/modebar_test.js +++ b/test/jasmine/tests/modebar_test.js @@ -1579,4 +1579,46 @@ describe('ModeBar', function() { .then(done); }); }); + + describe('modebar html', function() { + var gd; + var traces = [ + {type: 'scatter', x: [1, 2], y: [1, 2]}, + {type: 'scatter3d', x: [1, 2], y: [1, 2], z: [1, 2]}, + {type: 'surface', z: [[1, 2], [1, 2]]}, + {type: 'heatmap', z: [[1, 2], [1, 2]]}, + ]; + + beforeEach(function() { + gd = createGraphDiv(); + }); + + afterEach(function() { + Plotly.purge(gd); + destroyGraphDiv(); + }); + + function getModebarDiv() { + return document.getElementById('modebar-' + gd._fullLayout._uid); + } + + traces.forEach(function(fromTrace) { + traces.forEach(function(toTrace) { + it('is still present when switching from ' + fromTrace.type + ' to ' + toTrace.type, function(done) { + Plotly.plot(gd, [fromTrace], {}) + .then(function() { + expect(getModebarDiv()).toBeTruthy(); + expect(getModebarDiv().innerHTML).toBeTruthy(); + }) + .then(Plotly.react(gd, [toTrace])) + .then(function() { + expect(getModebarDiv()).toBeTruthy(); + expect(getModebarDiv().innerHTML).toBeTruthy(); + }) + .then(done) + .catch(failTest); + }); + }); + }); + }); });