Skip to content

Commit f25127c

Browse files
committed
don't coerce slider currentvalue attrs when !visible
1 parent 70610ec commit f25127c

File tree

2 files changed

+29
-8
lines changed

2 files changed

+29
-8
lines changed

src/components/sliders/defaults.js

+12-8
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,18 @@ function sliderDefaults(sliderIn, sliderOut, layoutOut) {
6565
coerce('pad.b');
6666
coerce('pad.l');
6767

68-
coerce('currentvalue.visible');
69-
coerce('currentvalue.xanchor');
70-
coerce('currentvalue.prefix');
71-
coerce('currentvalue.suffix');
72-
coerce('currentvalue.offset');
68+
Lib.coerceFont(coerce, 'font', layoutOut.font);
69+
70+
var currentValueIsVisible = coerce('currentvalue.visible');
71+
72+
if(currentValueIsVisible) {
73+
coerce('currentvalue.xanchor');
74+
coerce('currentvalue.prefix');
75+
coerce('currentvalue.suffix');
76+
coerce('currentvalue.offset');
77+
78+
Lib.coerceFont(coerce, 'currentvalue.font', sliderOut.font);
79+
}
7380

7481
coerce('transition.duration');
7582
coerce('transition.easing');
@@ -82,9 +89,6 @@ function sliderDefaults(sliderIn, sliderOut, layoutOut) {
8289
coerce('tickwidth');
8390
coerce('tickcolor');
8491
coerce('minorticklen');
85-
86-
Lib.coerceFont(coerce, 'font', layoutOut.font);
87-
Lib.coerceFont(coerce, 'currentvalue.font', sliderOut.font);
8892
}
8993

9094
function stepsDefaults(sliderIn, sliderOut) {

test/jasmine/tests/sliders_test.js

+17
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,23 @@ describe('sliders defaults', function() {
5757
expect(layoutOut.sliders[2].active).toBeUndefined();
5858
});
5959

60+
it('should not coerce currentvalue defaults unless currentvalue is visible', function() {
61+
layoutIn.sliders = [{
62+
currentvalue: {
63+
visible: false,
64+
xanchor: 'left'
65+
},
66+
steps: [
67+
{method: 'restyle', args: [], label: 'step0'},
68+
{method: 'restyle', args: [], label: 'step1'}
69+
]
70+
}];
71+
72+
supply(layoutIn, layoutOut);
73+
74+
expect(layoutOut.sliders[0].currentvalue.xanchor).toBeUndefined();
75+
});
76+
6077
it('should set the default values equal to the labels', function() {
6178
layoutIn.sliders = [{
6279
steps: [{

0 commit comments

Comments
 (0)