Skip to content

Commit 42e4b64

Browse files
committed
fix(slider): hide the slider when stats.min=stats.max
1 parent fc3e15f commit 42e4b64

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

src/widgets/range-slider/__tests__/range-slider-test.js

+43
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,49 @@ describe('rangeSlider()', () => {
9494
});
9595
});
9696

97+
context('when rangestats min === stats max', () => {
98+
beforeEach(() => {
99+
results = {
100+
disjunctiveFacets: [{
101+
name: 'aNumAttr',
102+
data: {
103+
65: 1
104+
},
105+
exhaustive: true,
106+
stats: {
107+
min: 65,
108+
max: 65,
109+
avg: 65,
110+
sum: 65
111+
}
112+
}]
113+
};
114+
});
115+
116+
it('should shouldAutoHideContainer', () => {
117+
widget.render({results, helper});
118+
119+
let props = {
120+
cssClasses: {body: null, root: null},
121+
onChange: () => {},
122+
pips: true,
123+
range: {max: 65, min: 65},
124+
shouldAutoHideContainer: true,
125+
start: [-Infinity, Infinity],
126+
step: 1,
127+
templateProps: {
128+
templates: {footer: '', header: ''},
129+
templatesConfig: undefined,
130+
transformData: undefined,
131+
useCustomCompileOptions: {footer: false, header: false}
132+
},
133+
tooltips: true
134+
};
135+
136+
expect(ReactDOM.render.firstCall.args[0]).toEqualJSX(<Slider {...props} />);
137+
});
138+
});
139+
97140
context('with results', () => {
98141
beforeEach(() => {
99142
results = {

src/widgets/range-slider/range-slider.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ function rangeSlider({
112112
};
113113
}
114114

115-
let hasNoRefinements = stats.min === null && stats.max === null;
115+
let hasNoRefinements = stats.min === stats.max;
116116

117117
let templateProps = utils.prepareTemplateProps({
118118
defaultTemplates,

0 commit comments

Comments
 (0)