Skip to content

Commit b47008f

Browse files
committed
clear all push margins objects if all menus get removed
1 parent ca26892 commit b47008f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/components/updatemenus/draw.js

+16
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ module.exports = function draw(gd) {
6464

6565
menus.exit().remove();
6666

67+
// remove push margin object(s)
68+
if(menus.exit().size()) clearPushMargins(gd);
69+
6770
// return early if no update menus are visible
6871
if(menuData.length === 0) return;
6972

@@ -435,3 +438,16 @@ function setItemPosition(item, menuOpts, posOpts) {
435438
function removeAllButtons(gButton) {
436439
gButton.selectAll('g.' + constants.buttonClassName).remove();
437440
}
441+
442+
function clearPushMargins(gd) {
443+
var pushMargins = gd._fullLayout._pushmargin || {},
444+
keys = Object.keys(pushMargins);
445+
446+
for(var i = 0; i < keys.length; i++) {
447+
var k = keys[i];
448+
449+
if(k.indexOf(constants.autoMarginIdRoot) !== -1) {
450+
Plots.autoMargin(gd, k);
451+
}
452+
}
453+
}

0 commit comments

Comments
 (0)