File tree 2 files changed +17
-9
lines changed
2 files changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -108,9 +108,6 @@ module.exports = function draw(gd) {
108
108
// find dimensions before plotting anything (this mutates menuOpts)
109
109
for ( var i = 0 ; i < menuData . length ; i ++ ) {
110
110
var menuOpts = menuData [ i ] ;
111
-
112
- // often more convenient than playing with two arguments
113
- menuOpts . _index = i ;
114
111
findDimenstions ( gd , menuOpts ) ;
115
112
}
116
113
@@ -128,19 +125,30 @@ module.exports = function draw(gd) {
128
125
129
126
function makeMenuData ( fullLayout ) {
130
127
var contOpts = fullLayout [ constants . name ] ,
131
- menuData = [ ] ;
128
+ menuData = [ ] ,
129
+ cnt = 0 ;
130
+
131
+ // Filter visible dropdowns and attach '_index' to each
132
+ // fullLayout options object to be used for 'object constancy'
133
+ // in the data join key function.
134
+ //
135
+ // Note that '_index' is relinked from update to update via
136
+ // Plots.supplyDefaults.
132
137
133
138
for ( var i = 0 ; i < contOpts . length ; i ++ ) {
134
139
var item = contOpts [ i ] ;
135
140
136
- if ( item . visible ) menuData . push ( item ) ;
141
+ if ( item . visible ) {
142
+ if ( ! item . _index ) item . _index = cnt ++ ;
143
+ menuData . push ( item ) ;
144
+ }
137
145
}
138
146
139
147
return menuData ;
140
148
}
141
149
142
- function keyFunction ( opts , i ) {
143
- return opts . visible + i ;
150
+ function keyFunction ( opts ) {
151
+ return opts . _index ;
144
152
}
145
153
146
154
function areMenuButtonsDropped ( gButton , menuOpts ) {
Original file line number Diff line number Diff line change @@ -167,8 +167,8 @@ describe('update menus interactions', function() {
167
167
168
168
Plotly . relayout ( gd , 'updatemenus[0].visible' , false ) . then ( function ( ) {
169
169
assertMenus ( [ 0 ] ) ;
170
- expect ( gd . _fullLayout . _pushmargin [ 'updatemenu-0' ] ) . toBeDefined ( ) ;
171
- expect ( gd . _fullLayout . _pushmargin [ 'updatemenu-1' ] ) . toBeUndefined ( ) ;
170
+ expect ( gd . _fullLayout . _pushmargin [ 'updatemenu-0' ] ) . toBeUndefined ( ) ;
171
+ expect ( gd . _fullLayout . _pushmargin [ 'updatemenu-1' ] ) . toBeDefined ( ) ;
172
172
173
173
return Plotly . relayout ( gd , 'updatemenus[1]' , null ) ;
174
174
} ) . then ( function ( ) {
You can’t perform that action at this time.
0 commit comments