Skip to content

Commit

Permalink
fix(rangeSlider): refinements cleanuo
Browse files Browse the repository at this point in the history
Do not add the numeric refinements if the values are equal to min/max to
cleanup the state+URL. Fix #147
  • Loading branch information
redox committed Oct 9, 2015
1 parent 0352b22 commit 16c132c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions widgets/range-slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,14 @@ function rangeSlider({
max
};
},
_refine(helper, newValues) {
_refine(helper, stats, newValues) {
helper.clearRefinements(facetName);
helper.addNumericRefinement(facetName, '>=', newValues[0]);
helper.addNumericRefinement(facetName, '<=', newValues[1]);
if (newValues[0] > stats.min) {
helper.addNumericRefinement(facetName, '>=', newValues[0]);
}
if (newValues[1] < stats.max) {
helper.addNumericRefinement(facetName, '<=', newValues[1]);
}
helper.search();
},
render({results, helper, templatesConfig}) {
Expand Down Expand Up @@ -101,7 +105,7 @@ function rangeSlider({
Template={bindProps(Template, templateProps)}
hideWhenNoResults={hideWhenNoResults}
hasResults={stats.min !== null && stats.max !== null}
onChange={this._refine.bind(this, helper)}
onChange={this._refine.bind(this, helper, stats)}
tooltips={tooltips}
/>,
containerNode
Expand Down

0 comments on commit 16c132c

Please sign in to comment.