Skip to content

Commit 5c9c60b

Browse files
authored
Merge pull request #5181 from Yook74/master
Fix modebar not recreated when makePlotFramework called
2 parents 3a7f28e + 629e21d commit 5c9c60b

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

src/plot_api/plot_api.js

+1
Original file line numberDiff line numberDiff line change
@@ -3751,6 +3751,7 @@ function makePlotFramework(gd) {
37513751
.classed('main-svg', true);
37523752

37533753
fullLayout._modebardiv = fullLayout._paperdiv.append('div');
3754+
delete fullLayout._modeBar;
37543755

37553756
fullLayout._hoverpaper = fullLayout._paperdiv.append('svg')
37563757
.classed('main-svg', true);

test/jasmine/tests/modebar_test.js

+42
Original file line numberDiff line numberDiff line change
@@ -1579,4 +1579,46 @@ describe('ModeBar', function() {
15791579
.then(done);
15801580
});
15811581
});
1582+
1583+
describe('modebar html', function() {
1584+
var gd;
1585+
var traces = [
1586+
{type: 'scatter', x: [1, 2], y: [1, 2]},
1587+
{type: 'scatter3d', x: [1, 2], y: [1, 2], z: [1, 2]},
1588+
{type: 'surface', z: [[1, 2], [1, 2]]},
1589+
{type: 'heatmap', z: [[1, 2], [1, 2]]},
1590+
];
1591+
1592+
beforeEach(function() {
1593+
gd = createGraphDiv();
1594+
});
1595+
1596+
afterEach(function() {
1597+
Plotly.purge(gd);
1598+
destroyGraphDiv();
1599+
});
1600+
1601+
function getModebarDiv() {
1602+
return document.getElementById('modebar-' + gd._fullLayout._uid);
1603+
}
1604+
1605+
traces.forEach(function(fromTrace) {
1606+
traces.forEach(function(toTrace) {
1607+
it('is still present when switching from ' + fromTrace.type + ' to ' + toTrace.type, function(done) {
1608+
Plotly.plot(gd, [fromTrace], {})
1609+
.then(function() {
1610+
expect(getModebarDiv()).toBeTruthy();
1611+
expect(getModebarDiv().innerHTML).toBeTruthy();
1612+
})
1613+
.then(Plotly.react(gd, [toTrace]))
1614+
.then(function() {
1615+
expect(getModebarDiv()).toBeTruthy();
1616+
expect(getModebarDiv().innerHTML).toBeTruthy();
1617+
})
1618+
.then(done)
1619+
.catch(failTest);
1620+
});
1621+
});
1622+
});
1623+
});
15821624
});

0 commit comments

Comments
 (0)