diff --git a/src/components/modebar/manage.js b/src/components/modebar/manage.js index 2a64c5efd53..24bef9578dc 100644 --- a/src/components/modebar/manage.js +++ b/src/components/modebar/manage.js @@ -27,9 +27,11 @@ module.exports = function manageModeBar(gd) { context = gd._context, modeBar = fullLayout._modeBar; - if(!context.displayModeBar && modeBar) { - modeBar.destroy(); - delete fullLayout._modeBar; + if(!context.displayModeBar) { + if(modeBar) { + modeBar.destroy(); + delete fullLayout._modeBar; + } return; } diff --git a/test/jasmine/tests/modebar_test.js b/test/jasmine/tests/modebar_test.js index 86d65b3780c..942663fbf9e 100644 --- a/test/jasmine/tests/modebar_test.js +++ b/test/jasmine/tests/modebar_test.js @@ -290,6 +290,14 @@ describe('ModeBar', function() { }); it('displays or not mode bar according to displayModeBar config arg', function() { + var gd = getMockGraphInfo(); + gd._context.displayModeBar = false; + + manageModeBar(gd); + expect(gd._fullLayout._modeBar).not.toBeDefined(); + }); + + it('updates mode bar according to displayModeBar config arg', function() { var gd = getMockGraphInfo(); manageModeBar(gd); expect(gd._fullLayout._modeBar).toBeDefined();