Skip to content

Commit df2d5bb

Browse files
committed
Revert updatemenus initialization and fix sliders initialization
1 parent 0c40b02 commit df2d5bb

File tree

6 files changed

+61
-7
lines changed

6 files changed

+61
-7
lines changed

src/components/sliders/attributes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ module.exports = {
6868
active: {
6969
valType: 'number',
7070
role: 'info',
71-
min: -10,
71+
min: 0,
7272
dflt: 0,
7373
description: [
7474
'Determines which button (by index starting from 0) is',

src/components/sliders/draw.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,9 @@ function drawSlider(gd, sliderGroup, sliderOpts) {
237237
// Position the rectangle:
238238
Lib.setTranslate(sliderGroup, sliderOpts.lx + sliderOpts.pad.l, sliderOpts.ly + sliderOpts.pad.t);
239239

240-
setActive(gd, sliderGroup, sliderOpts, sliderOpts.active, false, false);
240+
sliderGroup.call(setGripPosition, sliderOpts, sliderOpts.active / (sliderOpts.steps.length - 1), false);
241+
sliderGroup.call(drawCurrentValue, sliderOpts);
242+
241243
}
242244

243245
function drawCurrentValue(sliderGroup, sliderOpts, valueOverride) {

src/components/updatemenus/defaults.js

-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ module.exports = function updateMenusDefaults(layoutIn, layoutOut) {
3333
// used to determine object constancy
3434
menuOut._index = i;
3535

36-
menuOut._input.active = menuOut.active;
37-
3836
contOut.push(menuOut);
3937
}
4038
};

test/jasmine/tests/command_test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ describe('attaching component bindings', function() {
555555
expect(typeof gd._internalEv._events.plotly_animatingframe).toBe('function');
556556

557557
// Confirm the first position is selected:
558-
expect(gd.layout.sliders[0].active).toBe(0);
558+
expect(gd.layout.sliders[0].active).toBeUndefined();
559559

560560
// Modify the plot
561561
return Plotly.restyle(gd, {'marker.color': 'blue'});
@@ -608,7 +608,7 @@ describe('attaching component bindings', function() {
608608
expect(typeof gd._internalEv._events.plotly_animatingframe).toBe('function');
609609

610610
// Confirm the first position is selected:
611-
expect(gd.layout.updatemenus[0].active).toBe(0);
611+
expect(gd.layout.updatemenus[0].active).toBeUndefined();
612612

613613
// Modify the plot
614614
return Plotly.restyle(gd, {'marker.color': 'blue'});

test/jasmine/tests/sliders_test.js

+28-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,34 @@ describe('sliders defaults', function() {
182182
});
183183
});
184184

185-
describe('update sliders interactions', function() {
185+
describe('sliders initialization', function() {
186+
'use strict';
187+
var gd;
188+
189+
beforeEach(function(done) {
190+
gd = createGraphDiv();
191+
192+
Plotly.plot(gd, [{x: [1, 2, 3]}], {
193+
sliders: [{
194+
steps: [
195+
{method: 'restyle', args: [], label: 'first'},
196+
{method: 'restyle', args: [], label: 'second'},
197+
]
198+
}]
199+
}).then(done);
200+
});
201+
202+
afterEach(function() {
203+
Plotly.purge(gd);
204+
destroyGraphDiv();
205+
});
206+
207+
it('does not set active on initial plot', function() {
208+
expect(gd.layout.sliders[0].active).toBeUndefined();
209+
});
210+
});
211+
212+
describe('sliders interactions', function() {
186213
'use strict';
187214

188215
var mock = require('@mocks/sliders.json');

test/jasmine/tests/updatemenus_test.js

+27
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,33 @@ describe('update menus buttons', function() {
225225
}
226226
});
227227

228+
describe('update menus initialization', function() {
229+
'use strict';
230+
var gd;
231+
232+
beforeEach(function(done) {
233+
gd = createGraphDiv();
234+
235+
Plotly.plot(gd, [{x: [1, 2, 3]}], {
236+
updatemenus: [{
237+
buttons: [
238+
{method: 'restyle', args: [], label: 'first'},
239+
{method: 'restyle', args: [], label: 'second'},
240+
]
241+
}]
242+
}).then(done);
243+
});
244+
245+
afterEach(function() {
246+
Plotly.purge(gd);
247+
destroyGraphDiv();
248+
});
249+
250+
it('does not set active on initial plot', function() {
251+
expect(gd.layout.updatemenus[0].active).toBeUndefined();
252+
});
253+
});
254+
228255
describe('update menus interactions', function() {
229256
'use strict';
230257

0 commit comments

Comments
 (0)