Skip to content

Commit e0a10af

Browse files
committed
keep dropdown button container on top when new menus are added
1 parent 4e627d9 commit e0a10af

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

src/components/updatemenus/draw.js

+9-7
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ module.exports = function draw(gd) {
9797

9898
// remove exiting header, remove dropped buttons and reset margins
9999
if(headerGroups.enter().size()) {
100+
// make sure gButton is on top of all headers
101+
gButton.node().parentNode.appendChild(gButton.node());
102+
100103
gButton
101104
.call(removeAllButtons)
102105
.attr(constants.menuIndexAttrName, '-1');
@@ -135,13 +138,12 @@ module.exports = function draw(gd) {
135138
});
136139
};
137140

141+
/**
142+
* get only visible menus for display
143+
*/
138144
function makeMenuData(fullLayout) {
139-
var contOpts = fullLayout[constants.name],
140-
menuData = [];
141-
142-
// Filter visible dropdowns and attach '_index' to each
143-
// fullLayout options object to be used for 'object constancy'
144-
// in the data join key function.
145+
var contOpts = fullLayout[constants.name];
146+
var menuData = [];
145147

146148
for(var i = 0; i < contOpts.length; i++) {
147149
var item = contOpts[i];
@@ -154,7 +156,7 @@ function makeMenuData(fullLayout) {
154156

155157
// Note that '_index' is set at the default step,
156158
// it corresponds to the menu index in the user layout update menu container.
157-
// Because a menu can b set invisible,
159+
// Because a menu can be set invisible,
158160
// this is a more 'consistent' field than the index in the menuData.
159161
function keyFunction(menuOpts) {
160162
return menuOpts._index;

test/jasmine/tests/updatemenus_test.js

+4
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,10 @@ describe('update menus interactions', function() {
671671
// fold up buttons whenever new menus are added
672672
assertMenus([0, 0]);
673673

674+
// dropdown buttons container should still be on top of headers (and non-dropdown buttons)
675+
var gButton = d3.select('.updatemenu-dropdown-button-group');
676+
expect(gButton.node().nextSibling).toBe(null);
677+
674678
return Plotly.relayout(gd, {
675679
'updatemenus[0].bgcolor': null,
676680
'paper_bgcolor': 'black'

0 commit comments

Comments
 (0)